Skip to content

Commit b5615bf

Browse files
authored
Add support for operator labels and annotations (#2370)
* Add support for operator labels and annotations * Update to get --set to work and added documentation
1 parent 499304b commit b5615bf

File tree

3 files changed

+60
-13
lines changed

3 files changed

+60
-13
lines changed

documentation/staging/content/userguide/managing-operators/using-the-operator/using-helm.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ description: "Useful Helm operations."
1717
* [Debugging options](#debugging-options)
1818
* [Common mistakes and solutions](#common-mistakes-and-solutions)
1919

20-
Note that the operator Helm chart is available from the GitHub chart repository, see [Alternatively, install the operator Helm chart from the GitHub chart repository]({{< relref "/userguide/managing-operators/installation/_index.md#alternatively-install-the-operator-helm-chart-from-the-github-chart-repository" >}}).
20+
Note that the operator Helm chart is available from the GitHub chart repository. For more details, see [Alternatively, install the operator Helm chart from the GitHub chart repository]({{< relref "/userguide/managing-operators/installation/_index.md#alternatively-install-the-operator-helm-chart-from-the-github-chart-repository" >}}).
2121

2222
#### Useful Helm operations
2323

@@ -128,17 +128,47 @@ imagePullSecrets:
128128
- name: "my-image-pull-secret"
129129
```
130130

131+
##### `annotations`
132+
Specifies a set of key-value annotations that will be added to each pod running the operator. If no customer defined annotations are required, then omit this property.
133+
134+
Example:
135+
```yaml
136+
annotations:
137+
stage: production
138+
```
139+
140+
You may also specify annotations [using the `--set` parameter to the Helm install command](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing), as follows:
141+
142+
```
143+
--set annotations.stage=production
144+
```
145+
146+
##### `labels`
147+
Specifies a set of key-value labels that will be added to each pod running the operator. The Helm chart will automatically add any required labels, so the customer is not required to define those here. If no customer defined labels are required, then omit this property.
148+
149+
Example:
150+
```yaml
151+
labels:
152+
sidecar.istio.io/inject: "false"
153+
```
154+
155+
You may also specify labels [using the `--set` parameter to the Helm install command](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing), as follows:
156+
157+
```
158+
--set labels."sidecar\.istio\.io/inject"=false
159+
```
160+
131161
##### `nodeSelector`
132-
Allows you to run the operator Pod on a Node whose labels match the specified `nodeSelector` labels. You can use this optional feature if you want the operator Pod to run on a Node with particular labels. See [Assign Pods to Nodes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) in the Kubernetes documentation for more details. This is not required if the operator Pod can run on any Node.
162+
Allows you to run the operator Pod on a Node whose labels match the specified `nodeSelector` labels. You can use this optional feature if you want the operator Pod to run on a Node with particular labels. For more details, see [Assign Pods to Nodes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) in the Kubernetes documentation for more details. This is not required if the operator Pod can run on any Node.
133163

134164
Example:
135165
```yaml
136166
nodeSelector:
137167
disktype: ssd
138168
```
139169
140-
##### `nodeAffinity`
141-
Allows you to constrain the operator Pod to be scheduled on a Node with certain labels; it is conceptually similar to `nodeSelector`. `nodeAffinity` provides advanced capabilities to limit Pod placement on specific Nodes. See [Assign Pods to Nodes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity) in the Kubernetes documentation for more details. This is optional and not required if the operator Pod can run on any Node or when using `nodeSelector`.
170+
##### `affinity`
171+
Allows you to constrain the operator Pod to be scheduled on a Node with certain labels; it is conceptually similar to `nodeSelector`. `affinity` provides advanced capabilities to limit Pod placement on specific Nodes. For more details, see [Assign Pods to Nodes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity) in the Kubernetes documentation for more details. This is optional and not required if the operator Pod can run on any Node or when using `nodeSelector`.
142172

143173
Example:
144174
```yaml
@@ -233,7 +263,7 @@ You must include the `default` namespace in the list if you want the operator to
233263
This value is ignored if `dedicated` is set to `true`. Then, the operator will manage only domains in its own namespace.
234264
{{% /notice %}}
235265

236-
For more information about managing `domainNamespaces`, see [Managing domain namespaces]({{< relref "/faq/namespace-management.md" >}}).
266+
For more details about managing `domainNamespaces`, see [Managing domain namespaces]({{< relref "/faq/namespace-management.md" >}}).
237267

238268
##### `domainNamespaceLabelSelector`
239269
Specifies a [label selector](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors) that will be used when searching for namespaces that the operator will manage.
@@ -260,7 +290,7 @@ domainNamespaceLabelSelector: environment notin (production,systemtest)
260290

261291
{{% notice note %}}
262292
To specify the above sample on the Helm command line, escape spaces and commas as follows:
263-
```yaml
293+
```
264294
--set "domainNamespaceLabelSelector=environment\\ notin\\ (production\\,systemtest)"
265295
```
266296
{{% /notice %}}
@@ -322,7 +352,7 @@ Prior to the operator 3.1.0 release, the suffixes are hard-coded to `-introspect
322352
{{% /notice %}}
323353

324354
{{% notice note %}}
325-
In order to work with Kubernetes limits to resource names, the resultant names for the domain introspector job and the external service should not be more than 63 characters (see [Meet Kubernetes resource name restrictions]({{< relref "/userguide/managing-domains/_index.md#meet-kubernetes-resource-name-restrictions" >}})).
355+
In order to work with Kubernetes limits to resource names, the resultant names for the domain introspector job and the external service should not be more than 63 characters. For more details, see [Meet Kubernetes resource name restrictions]({{< relref "/userguide/managing-domains/_index.md#meet-kubernetes-resource-name-restrictions" >}}).
326356
{{% /notice %}}
327357

328358
##### `clusterSizePaddingValidationEnabled`
@@ -657,4 +687,4 @@ To recover:
657687
#### Deleting and recreating a namespace that an operator manages without informing the operator
658688

659689
If you create a new domain in a namespace that is deleted and recreated, the domain does not start up until you notify the operator.
660-
For more information about the problem and solutions, see [Managing domain namespaces]({{<relref "/faq/namespace-management.md">}}).
690+
For more details about the problem and solutions, see [Managing domain namespaces]({{<relref "/faq/namespace-management.md">}}).

kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,18 @@ spec:
1919
replicas: 1
2020
template:
2121
metadata:
22-
labels:
22+
{{- with .annotations }}
23+
annotations:
24+
{{- end }}
25+
{{- range $key, $value := .annotations }}
26+
{{ $key }}: {{ $value | quote }}
27+
{{- end }}
28+
labels:
2329
weblogic.operatorName: {{ .Release.Namespace | quote }}
2430
app: "weblogic-operator"
31+
{{- range $key, $value := .labels }}
32+
{{ $key }}: {{ $value | quote }}
33+
{{- end }}
2534
spec:
2635
serviceAccountName: {{ .serviceAccount | quote }}
2736
{{- with .nodeSelector }}
@@ -103,15 +112,15 @@ spec:
103112
livenessProbe:
104113
exec:
105114
command:
106-
- "bash"
107-
- "/operator/livenessProbe.sh"
115+
- "bash"
116+
- "/operator/livenessProbe.sh"
108117
initialDelaySeconds: 20
109118
periodSeconds: 5
110119
readinessProbe:
111120
exec:
112121
command:
113-
- "bash"
114-
- "/operator/readinessProbe.sh"
122+
- "bash"
123+
- "/operator/readinessProbe.sh"
115124
initialDelaySeconds: 2
116125
periodSeconds: 10
117126
{{- end }}

kubernetes/charts/weblogic-operator/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ javaLoggingFileSizeLimit: 20000000
137137
# directory as the files are rotated.
138138
javaLoggingFileCount: 10
139139

140+
# labels specifies a set of key-value labels that will be added to each pod running the operator.
141+
# See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
142+
#labels:
143+
144+
# annotations specifies a set of key-value annotations that will be added to each pod running the operator.
145+
# See https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
146+
#annotations:
147+
140148
# nodeSelector specifies a matching rule that the Kubernetes scheduler will use when selecting the node
141149
# where the operator will run. If the nodeSelector value is specified, then this content will be added to
142150
# the operator's deployment. See https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector

0 commit comments

Comments
 (0)