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. spec:
  6. type: bindings.kubernetes
  7. version: v1
  8. metadata:
  9. - name: namespace
  10. value: <NAMESPACE>
  11. - name: resyncPeriodInSec
  12. value: "<seconds>"

Spec metadata fields

FieldRequiredBinding supportDetailsExample
namespaceYInputThe Kubernetes namespace to read events from“default”
resyncPeriodInSecNInputThe 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. name: <ROLENAME>
  5. rules:
  6. - apiGroups: [""]
  7. resources: ["events"]
  8. verbs: ["get", "watch", "list"]

RoleBinding

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

Last modified July 27, 2022: Remove namespace element from component examples (#2647) (ff9de5c8)