Skip to content

Commit

Permalink
feat(helm/operator): statefulset labels and annotations (#7688)
Browse files Browse the repository at this point in the history
This updates the eck-operator Helm chart to support annotations and labels on the Statefulset for the operator. This is useful for telemetry and tracking.

Adds two new keys to values:
- statefulsetAnnotations -- defines the annotations that should be added to the operator StatefulSet
- statefulsetLabels -- defines additional labels that should be added to the operator StatefulSet

Updates deploy/eck-operator/templates/statefulset.yaml to support these new values

Adds a unit test.

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
Co-authored-by: Thibault Richard <thb.krkr@gmail.com>
  • Loading branch information
nromriell and thbkrkr authored Apr 25, 2024
1 parent e9681fe commit d1d4a48
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deploy/eck-operator/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ kind: StatefulSet
metadata:
name: {{ include "eck-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
{{- with .Values.statefulsetAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "eck-operator.labels" . | nindent 4 }}
{{- with .Values.statefulsetLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
Expand Down
22 changes: 22 additions & 0 deletions deploy/eck-operator/templates/tests/statefulset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,25 @@ tests:
equal:
path: spec.template.spec.automountServiceAccountToken
value: false
- it: should render custom labels, and annotations values properly
set:
statefulsetAnnotations:
key1: value1
statefulsetLabels:
key2: value2
asserts:
- template: statefulset.yaml
equal:
path: metadata.annotations
value:
key1: value1
- template: statefulset.yaml
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: elastic-operator
app.kubernetes.io/version: 2.13.0-SNAPSHOT
helm.sh/chart: eck-operator-2.13.0-SNAPSHOT
key2: value2
6 changes: 6 additions & 0 deletions deploy/eck-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ resources:
cpu: 100m
memory: 150Mi

# statefulsetAnnotations define the annotations that should be added to the operator StatefulSet.
statefulsetAnnotations: {}

# statefulsetLabels define additional labels that should be added to the operator StatefulSet.
statefulsetLabels: {}

# podAnnotations define the annotations that should be added to the operator pod.
podAnnotations: {}

Expand Down

0 comments on commit d1d4a48

Please sign in to comment.