ContainerSource reference

This topic provides reference information about the configurable fields for the ContainerSource object.

ContainerSource

A ContainerSource definition supports the following fields:

FieldDescriptionRequired or optional
apiVersionSpecifies the API version, for example sources.knative.dev/v1.Required
kindIdentifies this resource object as a ContainerSource object.Required
metadataSpecifies metadata that uniquely identifies the ContainerSource object. For example, a name.Required
specSpecifies the configuration information for this ContainerSource object.Required
spec.sinkA reference to an object that resolves to a URI to use as the sink.Required
spec.templateA template in the shape of Deployment.spec.template to be used for this ContainerSource.Required
spec.ceOverridesDefines overrides to control the output format and modifications to the event sent to the sink.Optional

Sink parameter

The sink parameter is a reference to an object that resolves to a URI to use as the sink.

A sink definition supports the following fields:

FieldDescriptionRequired or optional
refThis points to an Addressable.Required if not using uri
ref.apiVersionAPI version of the referent.Required if using ref
ref.kindKind of the referent.Required if using ref
ref.nameName of the referent.Required if using ref
ref.namespaceNamespace of the referent. If omitted this defaults to the object holding it.Optional
uriThis can be an absolute URL with a non-empty scheme and non-empty host that points to the target or a relative URI. Relative URIs are resolved using the base URI retrieved from Ref.Required if not using ref

Note

At least one of ref or uri is required. If both are specified, uri is resolved into the URL from the Addressable ref result.

Example: sink parameter

Given the following YAML, if ref resolves into "http://mysink.default.svc.cluster.local", then uri is added to this resulting in "http://mysink.default.svc.cluster.local/extra/path".

  1. apiVersion: sources.knative.dev/v1
  2. kind: ContainerSource
  3. metadata:
  4. name: test-heartbeats
  5. spec:
  6. ...
  7. sink:
  8. ref:
  9. apiVersion: v1
  10. kind: Service
  11. namespace: default
  12. name: mysink
  13. uri: /extra/path

Contract

This results in the K_SINK environment variable being set as "http://mysink.default.svc.cluster.local/extra/path".

Template parameter

This is a template in the shape of Deployment.spec.template to use for the ContainerSource. For more information, see the Kubernetes Documentation.

Example: template parameter

  1. apiVersion: sources.knative.dev/v1
  2. kind: ContainerSource
  3. metadata:
  4. name: test-heartbeats
  5. spec:
  6. template:
  7. spec:
  8. containers:
  9. - image: gcr.io/[gcloud-project]/knative.dev/eventing/cmd/heartbeats
  10. name: heartbeats
  11. args:
  12. - --period=1
  13. env:
  14. - name: POD_NAME
  15. value: "mypod"
  16. - name: POD_NAMESPACE
  17. value: "event-test"
  18. ...

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.

Example: CloudEvent Overrides

  1. apiVersion: sources.knative.dev/v1
  2. kind: ContainerSource
  3. metadata:
  4. name: test-heartbeats
  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" } }