Kubernetes Events binding spec

Detailed documentation on the Kubernetes Events binding component

Component format

To setup Kubernetes Events binding create a component of type bindings.kubernetes. See this guide on how to create and apply a binding configuration.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: bindings.kubernetes
  8. version: v1
  9. metadata:
  10. - name: namespace
  11. value: <NAMESPACE>
  12. - name: resyncPeriodInSec
  13. vale: "<seconds>"

Spec metadata fields

FieldRequiredBinding supportDetailsExample
namespaceYInputThe Kubernetes namespace to read events from“default”
resyncPeriodInSecNTe period of time to refresh event list from Kubernetes API server. Defaults to “10”“15”

Binding support

This component supports input binding interface.

Output format

Output received from the binding is of format bindings.ReadResponse with the Data field populated with the following structure:

  1. {
  2. "event": "",
  3. "oldVal": {
  4. "metadata": {
  5. "name": "hello-node.162c2661c524d095",
  6. "namespace": "kube-events",
  7. "selfLink": "/api/v1/namespaces/kube-events/events/hello-node.162c2661c524d095",
  8. ...
  9. },
  10. "involvedObject": {
  11. "kind": "Deployment",
  12. "namespace": "kube-events",
  13. ...
  14. },
  15. "reason": "ScalingReplicaSet",
  16. "message": "Scaled up replica set hello-node-7bf657c596 to 1",
  17. ...
  18. },
  19. "newVal": {
  20. "metadata": { "creationTimestamp": "null" },
  21. "involvedObject": {},
  22. "source": {},
  23. "firstTimestamp": "null",
  24. "lastTimestamp": "null",
  25. "eventTime": "null",
  26. ...
  27. }
  28. }

Three different event types are available:

  • Add : Only the newVal field is populated, oldVal field is an empty v1.Event, event is add
  • Delete : Only the oldVal field is populated, newVal field is an empty v1.Event, event is delete
  • Update : Both the oldVal and newVal fields are populated, event is update

Required permissions

For consuming events from Kubernetes, permissions need to be assigned to a User/Group/ServiceAccount using [RBAC Auth] mechanism of Kubernetes.

Role

One of the rules need to be of the form as below to give permissions to get, watch and list events. API Groups can be as restrictive as needed.

  1. apiVersion: rbac.authorization.k8s.io/v1
  2. kind: Role
  3. metadata:
  4. namespace: <NAMESPACE>
  5. name: <ROLENAME>
  6. rules:
  7. - apiGroups: [""]
  8. resources: ["events"]
  9. verbs: ["get", "watch", "list"]

RoleBinding

  1. apiVersion: rbac.authorization.k8s.io/v1
  2. kind: RoleBinding
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE> # same as above
  6. subjects:
  7. - kind: ServiceAccount
  8. name: default # or as need be, can be changed
  9. namespace: <NAMESPACE> # same as above
  10. roleRef:
  11. kind: Role
  12. name: <ROLENAME> # same as the one above
  13. apiGroup: ""

Related links

Last modified March 18, 2021: Merge pull request #1321 from dapr/aacrawfi/logos (9a399d5)