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

字段RequiredBinding 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”

Output bindings

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. }
  29. },
  30. "involvedObject": {
  31. "kind": "Deployment",
  32. "namespace": "kube-events",
  33. ...
  34. },
  35. "reason": "ScalingReplicaSet",
  36. "message": "Scaled up replica set hello-node-7bf657c596 to 1",
  37. ...
  38. },
  39. "newVal": {
  40. "metadata": { "creationTimestamp": "null" },
  41. "involvedObject": {},
  42. "source": {},
  43. "firstTimestamp": "null",
  44. "lastTimestamp": "null",
  45. "eventTime": "null",
  46. ...
  47. }
  48. }

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: ""

相关链接

Last modified January 1, 0001