Skip to content

Commit e37e86a

Browse files
authored
Allow additional labels and annotations to be specified when installing the Operator with Helm (#595)
1 parent e6358d6 commit e37e86a

File tree

4 files changed

+410
-0
lines changed

4 files changed

+410
-0
lines changed

docs/installation/01_installation.adoc

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ easily be installed into a Kubernetes cluster.
2626
*** <<helm-pull-secrets,Image Pull Secrets>>
2727
*** <<helm-watch-ns,Set the Watch Namespaces>>
2828
*** <<helm-sec-context,Install the Operator with a Security Context>>
29+
*** <<helm-labels,Set Additional Labels>>
30+
*** <<helm-annotations,Set Additional Annotations>>
2931
*** <<helm-uninstall,Uninstall the Coherence Operator Helm chart>>
3032
** <<kubectl,Kubectl with Kustomize>>
3133
** <<tanzu,VMWare Tanzu Package (kapp-controller)>>
@@ -433,6 +435,196 @@ helm install \
433435
coherence/coherence-operator
434436
----
435437
438+
[#helm-labels]
439+
=== Set Additional Labels
440+
441+
When installing the Operator with Helm, it is possible to set additional labels to be applied to the Operator Pods
442+
and to the Operator Deployment.
443+
444+
==== Adding Pod Labels
445+
446+
To add labels to the Operator Pods set the `labels` value, either on the command line using `--set` or in the values file.
447+
448+
[NOTE]
449+
====
450+
Setting `labels` will only apply the additional labels to the Operator Pods, they will not be applied to any other resource created by the Helm chart.
451+
====
452+
453+
For example, using the command line:
454+
455+
[source,bash]
456+
----
457+
helm install \
458+
--namespace <namespace> \
459+
--set labels.one=value-one \
460+
--set labels.two=value-two \
461+
coherence \
462+
coherence/coherence-operator
463+
----
464+
465+
The command above would add the following additional labels `one` and `two` to the Operator Pod as shown below:
466+
467+
[source,yaml]
468+
----
469+
apiVersion: v1
470+
kind: Pod
471+
metadata:
472+
name: coherence-operator
473+
labels:
474+
one: value-one
475+
two: value-two
476+
----
477+
478+
The same labels could also be specified in a values file:
479+
480+
[source]
481+
.add-labels-values.yaml
482+
----
483+
labels:
484+
one: value-one
485+
two: value-two
486+
----
487+
488+
==== Adding Deployment Labels
489+
490+
To add labels to the Operator Deployment set the `deploymentLabels` value, either on the command line using `--set` or in the values file.
491+
492+
[NOTE]
493+
====
494+
Setting `deploymentLabels` will only apply the additional labels to the Deployment, they will not be applied to any other resource created by the Helm chart.
495+
====
496+
497+
For example, using the command line:
498+
499+
[source,bash]
500+
----
501+
helm install \
502+
--namespace <namespace> \
503+
--set deploymentLabels.one=value-one \
504+
--set deploymentLabels.two=value-two \
505+
coherence \
506+
coherence/coherence-operator
507+
----
508+
509+
The command above would add the following additional labels `one` and `two` to the Operator Pod as shown below:
510+
511+
[source,yaml]
512+
----
513+
apiVersion: apps/v1
514+
kind: Deployment
515+
metadata:
516+
name: coherence-operator
517+
labels:
518+
one: value-one
519+
two: value-two
520+
----
521+
522+
The same labels could also be specified in a values file:
523+
524+
[source]
525+
.add-labels-values.yaml
526+
----
527+
deploymentLabels:
528+
one: value-one
529+
two: value-two
530+
----
531+
532+
533+
[#helm-annotations]
534+
=== Set Additional Annotations
535+
536+
When installing the Operator with Helm, it is possible to set additional annotations to be applied to the Operator Pods
537+
and to the Operator Deployment.
538+
539+
==== Adding Pod Annotations
540+
541+
To add annotations to the Operator Pods set the `annotations` value, either on the command line using `--set` or in the values file.
542+
543+
[NOTE]
544+
====
545+
Setting `annotations` will only apply the additional annotations to the Operator Pods, they will not be applied to any other resource created by the Helm chart.
546+
====
547+
548+
For example, using the command line:
549+
550+
[source,bash]
551+
----
552+
helm install \
553+
--namespace <namespace> \
554+
--set annotations.one=value-one \
555+
--set annotations.two=value-two \
556+
coherence \
557+
coherence/coherence-operator
558+
----
559+
560+
The command above would add the following additional annotations `one` and `two` to the Operator Pod as shown below:
561+
562+
[source,yaml]
563+
----
564+
apiVersion: v1
565+
kind: Pod
566+
metadata:
567+
name: coherence-operator
568+
annotations:
569+
one: value-one
570+
two: value-two
571+
----
572+
573+
The same annotations could also be specified in a values file:
574+
575+
[source]
576+
.add-annotations-values.yaml
577+
----
578+
annotations:
579+
one: value-one
580+
two: value-two
581+
----
582+
583+
==== Adding Deployment Annotations
584+
585+
To add annotations to the Operator Deployment set the `deploymentAnnotations` value, either on the command line using `--set` or in the values file.
586+
587+
[NOTE]
588+
====
589+
Setting `deploymentAnnotations` will only apply the additional annotations to the Deployment, they will not be applied to any other resource created by the Helm chart.
590+
====
591+
592+
For example, using the command line:
593+
594+
[source,bash]
595+
----
596+
helm install \
597+
--namespace <namespace> \
598+
--set deploymentAnnotations.one=value-one \
599+
--set deploymentAnnotations.two=value-two \
600+
coherence \
601+
coherence/coherence-operator
602+
----
603+
604+
The command above would add the following additional annotations `one` and `two` to the Operator Pod as shown below:
605+
606+
[source,yaml]
607+
----
608+
apiVersion: apps/v1
609+
kind: Deployment
610+
metadata:
611+
name: coherence-operator
612+
annotations:
613+
one: value-one
614+
two: value-two
615+
----
616+
617+
The same annotations could also be specified in a values file:
618+
619+
[source]
620+
.add-annotations-values.yaml
621+
----
622+
deploymentAnnotations:
623+
one: value-one
624+
two: value-two
625+
----
626+
627+
436628
[#helm-uninstall]
437629
=== Uninstall the Coherence Operator Helm chart
438630

helm-charts/coherence-operator/templates/deployment.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ metadata:
6969
app.kubernetes.io/part-of: coherence-operator
7070
app.kubernetes.io/managed-by: helm
7171
app.kubernetes.io/created-by: controller-manager
72+
{{- if .Values.deploymentLabels }}
73+
{{ toYaml .Values.deploymentLabels | indent 4 }}
74+
{{- end }}
75+
{{- if .Values.deploymentAnnotations }}
76+
annotations:
77+
{{ toYaml .Values.deploymentAnnotations | indent 4 }}
78+
{{- end }}
7279
spec:
7380
replicas: {{ default 3 .Values.replicas }}
7481
selector:
@@ -85,6 +92,13 @@ spec:
8592
app.kubernetes.io/part-of: coherence-operator
8693
app.kubernetes.io/managed-by: helm
8794
app.kubernetes.io/created-by: controller-manager
95+
{{- if .Values.labels }}
96+
{{ toYaml .Values.labels | indent 8 }}
97+
{{- end }}
98+
{{- if .Values.annotations }}
99+
annotations:
100+
{{ toYaml .Values.annotations | indent 8 }}
101+
{{- end }}
88102
spec:
89103
serviceAccountName: {{ default "coherence-operator" .Values.serviceAccountName }}
90104
{{- if .Values.podSecurityContext }}

helm-charts/coherence-operator/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ replicas: 3
4444
# - name: "bar"
4545
imagePullSecrets:
4646

47+
# ---------------------------------------------------------------------------
48+
# Additional labels that are added to the Operator Pods.
49+
labels:
50+
51+
# ---------------------------------------------------------------------------
52+
# Additional annotations that are added to the Operator Pods.
53+
annotations:
54+
55+
# ---------------------------------------------------------------------------
56+
# Additional labels that are added to the Operator Deployment.
57+
deploymentLabels:
58+
59+
# ---------------------------------------------------------------------------
60+
# Additional annotations that are added to the Operator Deployment.
61+
deploymentAnnotations:
62+
4763
# ---------------------------------------------------------------------------
4864
# Operator Pod securityContext
4965
# This sets the securityContext configuration for the Pod, for example

0 commit comments

Comments
 (0)