跳至内容

ContainerSource 参考

API version v1

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

ContainerSource

ContainerSource 定义支持以下字段

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

模板参数

这是一个形状与 Deployment.spec.template 相同的 template,用于 ContainerSource。有关更多信息,请参阅Kubernetes 文档

示例:模板参数

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 覆盖

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

ceOverrides 定义支持以下字段

字段 描述 必需或可选
extensions 指定在出站事件上添加或覆盖哪些属性。每个 extensions 键值对在事件上作为属性扩展独立设置。 可选

注意

仅允许有效的CloudEvent 属性名称 作为扩展。您无法从扩展覆盖配置中设置规范定义的属性。例如,您不能修改 type 属性。

示例:CloudEvent 覆盖

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

合约

这将导致 K_CE_OVERRIDES 环境变量在 subject 上设置如下

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

我们使用分析和 Cookie 来了解网站流量。关于您使用我们网站的信息将与 Google 共享,以用于该目的。 了解更多。