Skip to content

ContainerSource 参考

API version v1

本主题提供有关ContainerSource对象的可配置字段的参考信息。

ContainerSource

ContainerSource定义支持以下字段:

Field Description 必须 or 可选
apiVersion 指定API版本,例如 sources.knative.dev/v1. 必须
kind 将此资源对象标识为ContainerSource对象。 必须
metadata 指定唯一标识ContainerSource对象的元数据。例如, a name. 必须
spec 指定此ContainerSource对象的配置信息。 必须
spec.sink 对解析为用作接收器的URI的对象的引用。 必须
spec.template 一个形状为Deployment.spec.templatetemplate,用于此ContainerSource。 必须
spec.ceOverrides 定义覆盖以控制发送到接收器的事件的输出格式和修改。 可选

模板参数

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

示例:模板参数

apiVersion: sources.knative.dev/v1
kind: ContainerSource
metadata:
  name: test-heartbeats
spec:
  template:
    spec:
      containers:
        - image: gcr.io/knative-nightly/knative.dev/eventing/cmd/heartbeats
          name: heartbeats
          args:
            - --period=1
          env:
            - name: POD_NAME
              value: "mypod"
            - name: POD_NAMESPACE
              value: "event-test"
  ...

CloudEvent Overrides

CloudEvent Overrides定义了覆盖来控制发送到接收器的事件的输出格式和修改。

A ceOverrides definition supports the following fields:

Field Description 必须 or 可选
extensions Specifies 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. 可选

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

apiVersion: sources.knative.dev/v1
kind: ContainerSource
metadata:
  name: test-heartbeats
spec:
  ...
  ceOverrides:
    extensions:
      extra: this is an extra attribute
      additional: 42

Contract

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

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

Back to top

We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.

× OK