Skip to content

Commit

Permalink
Allow additional labels and annotations to be specified when installi…
Browse files Browse the repository at this point in the history
…ng the Operator with Helm (#595)
  • Loading branch information
thegridman authored Apr 25, 2023
1 parent e6358d6 commit e37e86a
Show file tree
Hide file tree
Showing 4 changed files with 410 additions and 0 deletions.
192 changes: 192 additions & 0 deletions docs/installation/01_installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ easily be installed into a Kubernetes cluster.
*** <<helm-pull-secrets,Image Pull Secrets>>
*** <<helm-watch-ns,Set the Watch Namespaces>>
*** <<helm-sec-context,Install the Operator with a Security Context>>
*** <<helm-labels,Set Additional Labels>>
*** <<helm-annotations,Set Additional Annotations>>
*** <<helm-uninstall,Uninstall the Coherence Operator Helm chart>>
** <<kubectl,Kubectl with Kustomize>>
** <<tanzu,VMWare Tanzu Package (kapp-controller)>>
Expand Down Expand Up @@ -433,6 +435,196 @@ helm install \
coherence/coherence-operator
----
[#helm-labels]
=== Set Additional Labels
When installing the Operator with Helm, it is possible to set additional labels to be applied to the Operator Pods
and to the Operator Deployment.
==== Adding Pod Labels
To add labels to the Operator Pods set the `labels` value, either on the command line using `--set` or in the values file.
[NOTE]
====
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.
====
For example, using the command line:
[source,bash]
----
helm install \
--namespace <namespace> \
--set labels.one=value-one \
--set labels.two=value-two \
coherence \
coherence/coherence-operator
----
The command above would add the following additional labels `one` and `two` to the Operator Pod as shown below:
[source,yaml]
----
apiVersion: v1
kind: Pod
metadata:
name: coherence-operator
labels:
one: value-one
two: value-two
----
The same labels could also be specified in a values file:
[source]
.add-labels-values.yaml
----
labels:
one: value-one
two: value-two
----
==== Adding Deployment Labels
To add labels to the Operator Deployment set the `deploymentLabels` value, either on the command line using `--set` or in the values file.
[NOTE]
====
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.
====
For example, using the command line:
[source,bash]
----
helm install \
--namespace <namespace> \
--set deploymentLabels.one=value-one \
--set deploymentLabels.two=value-two \
coherence \
coherence/coherence-operator
----
The command above would add the following additional labels `one` and `two` to the Operator Pod as shown below:
[source,yaml]
----
apiVersion: apps/v1
kind: Deployment
metadata:
name: coherence-operator
labels:
one: value-one
two: value-two
----
The same labels could also be specified in a values file:
[source]
.add-labels-values.yaml
----
deploymentLabels:
one: value-one
two: value-two
----
[#helm-annotations]
=== Set Additional Annotations
When installing the Operator with Helm, it is possible to set additional annotations to be applied to the Operator Pods
and to the Operator Deployment.
==== Adding Pod Annotations
To add annotations to the Operator Pods set the `annotations` value, either on the command line using `--set` or in the values file.
[NOTE]
====
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.
====
For example, using the command line:
[source,bash]
----
helm install \
--namespace <namespace> \
--set annotations.one=value-one \
--set annotations.two=value-two \
coherence \
coherence/coherence-operator
----
The command above would add the following additional annotations `one` and `two` to the Operator Pod as shown below:
[source,yaml]
----
apiVersion: v1
kind: Pod
metadata:
name: coherence-operator
annotations:
one: value-one
two: value-two
----
The same annotations could also be specified in a values file:
[source]
.add-annotations-values.yaml
----
annotations:
one: value-one
two: value-two
----
==== Adding Deployment Annotations
To add annotations to the Operator Deployment set the `deploymentAnnotations` value, either on the command line using `--set` or in the values file.
[NOTE]
====
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.
====
For example, using the command line:
[source,bash]
----
helm install \
--namespace <namespace> \
--set deploymentAnnotations.one=value-one \
--set deploymentAnnotations.two=value-two \
coherence \
coherence/coherence-operator
----
The command above would add the following additional annotations `one` and `two` to the Operator Pod as shown below:
[source,yaml]
----
apiVersion: apps/v1
kind: Deployment
metadata:
name: coherence-operator
annotations:
one: value-one
two: value-two
----
The same annotations could also be specified in a values file:
[source]
.add-annotations-values.yaml
----
deploymentAnnotations:
one: value-one
two: value-two
----
[#helm-uninstall]
=== Uninstall the Coherence Operator Helm chart
Expand Down
14 changes: 14 additions & 0 deletions helm-charts/coherence-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ metadata:
app.kubernetes.io/part-of: coherence-operator
app.kubernetes.io/managed-by: helm
app.kubernetes.io/created-by: controller-manager
{{- if .Values.deploymentLabels }}
{{ toYaml .Values.deploymentLabels | indent 4 }}
{{- end }}
{{- if .Values.deploymentAnnotations }}
annotations:
{{ toYaml .Values.deploymentAnnotations | indent 4 }}
{{- end }}
spec:
replicas: {{ default 3 .Values.replicas }}
selector:
Expand All @@ -85,6 +92,13 @@ spec:
app.kubernetes.io/part-of: coherence-operator
app.kubernetes.io/managed-by: helm
app.kubernetes.io/created-by: controller-manager
{{- if .Values.labels }}
{{ toYaml .Values.labels | indent 8 }}
{{- end }}
{{- if .Values.annotations }}
annotations:
{{ toYaml .Values.annotations | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ default "coherence-operator" .Values.serviceAccountName }}
{{- if .Values.podSecurityContext }}
Expand Down
16 changes: 16 additions & 0 deletions helm-charts/coherence-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ replicas: 3
# - name: "bar"
imagePullSecrets:

# ---------------------------------------------------------------------------
# Additional labels that are added to the Operator Pods.
labels:

# ---------------------------------------------------------------------------
# Additional annotations that are added to the Operator Pods.
annotations:

# ---------------------------------------------------------------------------
# Additional labels that are added to the Operator Deployment.
deploymentLabels:

# ---------------------------------------------------------------------------
# Additional annotations that are added to the Operator Deployment.
deploymentAnnotations:

# ---------------------------------------------------------------------------
# Operator Pod securityContext
# This sets the securityContext configuration for the Pod, for example
Expand Down
Loading

0 comments on commit e37e86a

Please sign in to comment.