From 0b804aef62e67c47de39c5340f0e4d612739d212 Mon Sep 17 00:00:00 2001 From: nromriell Date: Thu, 4 Apr 2024 07:32:21 -0700 Subject: [PATCH 1/2] feat(helm): statefulset labels and annotations Signed-off-by: nromriell --- deploy/eck-operator/templates/statefulset.yaml | 7 +++++++ deploy/eck-operator/values.yaml | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/deploy/eck-operator/templates/statefulset.yaml b/deploy/eck-operator/templates/statefulset.yaml index 7f6a8f716b..00a6a0c7a4 100644 --- a/deploy/eck-operator/templates/statefulset.yaml +++ b/deploy/eck-operator/templates/statefulset.yaml @@ -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: diff --git a/deploy/eck-operator/values.yaml b/deploy/eck-operator/values.yaml index 6a12465082..b785e85c1e 100644 --- a/deploy/eck-operator/values.yaml +++ b/deploy/eck-operator/values.yaml @@ -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: {} From ac844fb3c3e6b3fe420e12fabcb0f375fa40a1f2 Mon Sep 17 00:00:00 2001 From: Thibault Richard Date: Thu, 25 Apr 2024 18:22:37 +0200 Subject: [PATCH 2/2] Add unit test --- .../templates/tests/statefulset_test.yaml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/deploy/eck-operator/templates/tests/statefulset_test.yaml b/deploy/eck-operator/templates/tests/statefulset_test.yaml index b78fd80810..a2ded61650 100644 --- a/deploy/eck-operator/templates/tests/statefulset_test.yaml +++ b/deploy/eck-operator/templates/tests/statefulset_test.yaml @@ -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