SinkBinding reference

API version v1

This topic provides reference information about the configurable parameters for SinkBinding objects.

Supported parameters

A SinkBinding resource supports the following parameters:

FieldDescriptionRequired or optional
apiVersionSpecifies the API version, for example sources.knative.dev/v1.Required
kindIdentifies this resource object as a SinkBinding object.Required
metadataSpecifies metadata that uniquely identifies the SinkBinding object. For example, a name.Required
specSpecifies the configuration information for this SinkBinding object.Required
spec.sinkA reference to an object that resolves to a URI to use as the sink.Required
spec.subjectA reference to the resources for which the “runtime contract” is augmented by Binding implementations.Required
spec.ceOverridesDefines overrides to control the output format and modifications to the event sent to the sink.Optional

Subject parameter

The Subject parameter references the resources for which the “runtime contract” is augmented by Binding implementations.

A subject definition supports the following fields:

FieldDescriptionRequired or optional
apiVersionAPI version of the referent.Required
kindKind of the referent.Required
namespaceNamespace of the referent. If omitted, this defaults to the object holding it.Optional
nameName of the referent.Do not use if you configure selector.
selectorSelector of the referents.Do not use if you configure name.
selector.matchExpressionsA list of label selector requirements. The requirements are ANDed.Use one of matchExpressions or matchLabels
selector.matchExpressions.keyThe label key that the selector applies to.Required if using matchExpressions
selector.matchExpressions.operatorRepresents a key’s relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.Required if using matchExpressions
selector.matchExpressions.valuesAn array of string values. If operator is In or NotIn, the values array must be non-empty. If operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.Required if using matchExpressions
selector.matchLabelsA map of key-value pairs. Each key-value pair in the matchLabels map is equivalent to an element of matchExpressions, where the key field is matchLabels.<key>, the operator is In, and the values array contains only “matchLabels.“. The requirements are ANDed.Use one of matchExpressions or matchLabels

Subject parameter examples

Given the following YAML, the Deployment named mysubject in the default namespace is selected:

  1. apiVersion: sources.knative.dev/v1
  2. kind: SinkBinding
  3. metadata:
  4. name: bind-heartbeat
  5. spec:
  6. subject:
  7. apiVersion: apps/v1
  8. kind: Deployment
  9. namespace: default
  10. name: mysubject
  11. ...

Given the following YAML, any Job with the label working=example in the default namespace is selected:

  1. apiVersion: sources.knative.dev/v1
  2. kind: SinkBinding
  3. metadata:
  4. name: bind-heartbeat
  5. spec:
  6. subject:
  7. apiVersion: batch/v1
  8. kind: Job
  9. namespace: default
  10. selector:
  11. matchLabels:
  12. working: example
  13. ...

Given the following YAML, any Pod with the label working=example OR working=sample in the default namespace is selected:

  1. apiVersion: sources.knative.dev/v1
  2. kind: SinkBinding
  3. metadata:
  4. name: bind-heartbeat
  5. spec:
  6. subject:
  7. apiVersion: v1
  8. kind: Pod
  9. namespace: default
  10. selector:
  11. - matchExpression:
  12. key: working
  13. operator: In
  14. values:
  15. - example
  16. - sample
  17. ...

CloudEvent Overrides

CloudEvent Overrides defines overrides to control the output format and modifications of the event sent to the sink.

A ceOverrides definition supports the following fields:

FieldDescriptionRequired or optional
extensionsSpecifies which attributes are added or overridden on the outbound event. Each extensions key-value pair is set independently on the event as an attribute extension.Optional

Note

Only valid CloudEvent attribute names are allowed as extensions. You cannot set the spec defined attributes from the extensions override configuration. For example, you can not modify the type attribute.

CloudEvent Overrides example

  1. apiVersion: sources.knative.dev/v1
  2. kind: SinkBinding
  3. metadata:
  4. name: bind-heartbeat
  5. spec:
  6. ...
  7. ceOverrides:
  8. extensions:
  9. extra: this is an extra attribute
  10. additional: 42

Contract

This results in the K_CE_OVERRIDES environment variable being set on the subject as follows:

  1. { "extensions": { "extra": "this is an extra attribute", "additional": "42" } }