|
| 1 | +[id="serverless-sinkbinding-reference_{context}"] |
| 2 | += Sink binding reference |
| 3 | + |
| 4 | +This topic provides reference information about the configurable parameters for `SinkBinding` objects. |
| 5 | + |
| 6 | +`SinkBinding` objects support the following parameters: |
| 7 | + |
| 8 | +[cols=3*,options="header"] |
| 9 | +|=== |
| 10 | +|Field |
| 11 | +|Description |
| 12 | +|Required or optional |
| 13 | + |
| 14 | +|`apiVersion` |
| 15 | +|Specifies the API version, for example `sources.knative.dev/v1`. |
| 16 | +|Required |
| 17 | + |
| 18 | +|`kind` |
| 19 | +|Identifies this resource object as a `SinkBinding` object. |
| 20 | +|Required |
| 21 | + |
| 22 | +|`metadata` |
| 23 | +|Specifies metadata that uniquely identifies the `SinkBinding` object. For example, a `name`. |
| 24 | +|Required |
| 25 | + |
| 26 | +|`spec` |
| 27 | +|Specifies the configuration information for this `SinkBinding` object. |
| 28 | +|Required |
| 29 | + |
| 30 | +|`spec.sink` |
| 31 | +|A reference to an object that resolves to a URI to use as the sink. |
| 32 | +|Required |
| 33 | + |
| 34 | +|`spec.subject` |
| 35 | +|References the resources for which the runtime contract is augmented by binding implementations. |
| 36 | +|Required |
| 37 | + |
| 38 | +|`spec.ceOverrides` |
| 39 | +|Defines overrides to control the output format and modifications to the event sent to the sink. |
| 40 | +|Optional |
| 41 | + |
| 42 | +|=== |
| 43 | + |
| 44 | +[id="serverless-sinkbinding-reference-subject-parameters_{context}"] |
| 45 | +== Subject parameter |
| 46 | + |
| 47 | +The `Subject` parameter references the resources for which the runtime contract is augmented by binding implementations. |
| 48 | + |
| 49 | +The `Subject` definition supports the following fields: |
| 50 | + |
| 51 | +[cols=3*,options="header"] |
| 52 | +|=== |
| 53 | +|Field |
| 54 | +|Description |
| 55 | +|Required or optional |
| 56 | + |
| 57 | +|`apiVersion` |
| 58 | +|API version of the referent. |
| 59 | +|Required |
| 60 | + |
| 61 | +|`kind` |
| 62 | +|Kind of the referent. |
| 63 | +|Required |
| 64 | + |
| 65 | +|`namespace` |
| 66 | +|Namespace of the referent. If omitted, this defaults to the namespace of the object. |
| 67 | +|Optional |
| 68 | + |
| 69 | +|`name` |
| 70 | +|Name of the referent. |
| 71 | +|Do not use if you configure `selector`. |
| 72 | + |
| 73 | +|`selector` |
| 74 | +|Selector of the referents. |
| 75 | +|Do not use if you configure `name`. |
| 76 | + |
| 77 | +|`selector.matchExpressions` |
| 78 | +|A list of label selector requirements. |
| 79 | +|Only use one of either `matchExpressions` or `matchLabels`. |
| 80 | + |
| 81 | +|`selector.matchExpressions.key` |
| 82 | +|The label key that the selector applies to. |
| 83 | +|Required if using `matchExpressions`. |
| 84 | + |
| 85 | +|`selector.matchExpressions.operator` |
| 86 | +|Represents a key's relationship to a set of values. Valid operators are `In`, `NotIn`, `Exists` and `DoesNotExist`. |
| 87 | +|Required if using `matchExpressions`. |
| 88 | + |
| 89 | +|`selector.matchExpressions.values` |
| 90 | +|An array of string values. If the `operator` parameter value is `In` or `NotIn`, the values array must be non-empty. If the `operator` parameter value is `Exists` or `DoesNotExist`, the values array must be empty. This array is replaced during a strategic merge patch. |
| 91 | +|Required if using `matchExpressions`. |
| 92 | + |
| 93 | +|`selector.matchLabels` |
| 94 | +|A 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.<value>`. |
| 95 | +|Only use one of either `matchExpressions` or `matchLabels`. |
| 96 | + |
| 97 | +|=== |
| 98 | + |
| 99 | +[id="serverless-sinkbinding-reference-subject-parameter-examples_{context}"] |
| 100 | +=== Subject parameter examples |
| 101 | + |
| 102 | +Given the following YAML, the `Deployment` object named `mysubject` in the `default` namespace is selected: |
| 103 | + |
| 104 | +[source,yaml] |
| 105 | +---- |
| 106 | +apiVersion: sources.knative.dev/v1 |
| 107 | +kind: SinkBinding |
| 108 | +metadata: |
| 109 | + name: bind-heartbeat |
| 110 | +spec: |
| 111 | + subject: |
| 112 | + apiVersion: apps/v1 |
| 113 | + kind: Deployment |
| 114 | + namespace: default |
| 115 | + name: mysubject |
| 116 | + ... |
| 117 | +---- |
| 118 | + |
| 119 | +Given the following YAML, any `Job` object with the label `working=example` in the `default` namespace is selected: |
| 120 | + |
| 121 | +[source,yaml] |
| 122 | +---- |
| 123 | +apiVersion: sources.knative.dev/v1 |
| 124 | +kind: SinkBinding |
| 125 | +metadata: |
| 126 | + name: bind-heartbeat |
| 127 | +spec: |
| 128 | + subject: |
| 129 | + apiVersion: batch/v1 |
| 130 | + kind: Job |
| 131 | + namespace: default |
| 132 | + selector: |
| 133 | + matchLabels: |
| 134 | + working: example |
| 135 | + ... |
| 136 | +---- |
| 137 | + |
| 138 | +Given the following YAML, any `Pod` object with the label `working=example` or `working=sample` in the `default` namespace is selected: |
| 139 | + |
| 140 | +[source,yaml] |
| 141 | +---- |
| 142 | +apiVersion: sources.knative.dev/v1 |
| 143 | +kind: SinkBinding |
| 144 | +metadata: |
| 145 | + name: bind-heartbeat |
| 146 | +spec: |
| 147 | + subject: |
| 148 | + apiVersion: v1 |
| 149 | + kind: Pod |
| 150 | + namespace: default |
| 151 | + selector: |
| 152 | + - matchExpression: |
| 153 | + key: working |
| 154 | + operator: In |
| 155 | + values: |
| 156 | + - example |
| 157 | + - sample |
| 158 | + ... |
| 159 | +---- |
| 160 | + |
| 161 | +[id="serverless-sinkbinding-reference-cloudevent-overrides_{context}"] |
| 162 | +== CloudEvent overrides |
| 163 | + |
| 164 | +A `ceOverrides` definition provides overrides that control the CloudEvent's output format and modifications sent to the sink |
| 165 | + |
| 166 | +A `ceOverrides` definition supports the following fields: |
| 167 | + |
| 168 | +[cols=3*,options="header"] |
| 169 | +|=== |
| 170 | +|Field |
| 171 | +|Description |
| 172 | +|Required or optional |
| 173 | + |
| 174 | +|`extensions` |
| 175 | +|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. |
| 176 | +|Optional |
| 177 | + |
| 178 | +|=== |
| 179 | + |
| 180 | +[NOTE] |
| 181 | +==== |
| 182 | +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. |
| 183 | +==== |
| 184 | + |
| 185 | +.CloudEvent Overrides example |
| 186 | +[source,yaml] |
| 187 | +---- |
| 188 | +apiVersion: sources.knative.dev/v1 |
| 189 | +kind: SinkBinding |
| 190 | +metadata: |
| 191 | + name: bind-heartbeat |
| 192 | +spec: |
| 193 | + ... |
| 194 | + ceOverrides: |
| 195 | + extensions: |
| 196 | + extra: this is an extra attribute |
| 197 | + additional: 42 |
| 198 | +---- |
| 199 | + |
| 200 | +This sets the `K_CE_OVERRIDES` environment variable on the `subject`: |
| 201 | + |
| 202 | +.Example output |
| 203 | +[source,terminal] |
| 204 | +---- |
| 205 | +{ "extensions": { "extra": "this is an extra attribute", "additional": "42" } } |
| 206 | +---- |
0 commit comments