Configure Sugar Controller

This topic describes how to configure the Sugar Controller. You can configure the Sugar controller to create a Broker when a Namespace or Trigger is created with configured labels. See Knative Eventing Sugar Controller for an example.

The default config-sugar ConfigMap disables Sugar Controller, by setting namespace-selector and trigger-selector to an empty string.

To enable the Sugar Controller

  • for Namespaces, the LabelSelector namespace-selector can be configured.
  • for Triggers, the LabelSelector trigger-selector can be configured.

Sample configuration to enable Sugar Controller on selected Namespaces and Triggers

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-sugar
  5. namespace: knative-eventing
  6. labels:
  7. eventing.knative.dev/release: devel
  8. data:
  9. namespace-selector: |
  10. matchExpressions:
  11. - key: "eventing.knative.dev/injection"
  12. operator: "In"
  13. values: ["enabled"]
  14. trigger-selector: |
  15. matchExpressions:
  16. - key: "eventing.knative.dev/injection"
  17. operator: "In"
  18. values: ["enabled"]

The Sugar Controller will only operate on Namespaces or Triggers with the label eventing.knative.dev/injection: enabled. This also emulates the legacy Sugar Controller behavior for Namespaces.

You can edit this ConfigMap by running the command:

  1. kubectl edit cm config-sugar -n knative-eventing