From 719765a72d2eaa1a5d45aa0530f252dd27e5786c Mon Sep 17 00:00:00 2001 From: m4r1u2 <37156811+m4r1u2@users.noreply.github.com> Date: Fri, 17 Nov 2023 03:31:27 +0100 Subject: [PATCH] add podLabels to helm (#3167) # What this PR does Add option to add additional pod labels. ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) - [x] It is manually tested in the internal environment --------- Co-authored-by: Marius Ensrud Co-authored-by: Joey Orlando Co-authored-by: Joey Orlando Co-authored-by: Ildar Iskhakov --- helm/oncall/templates/celery/deployment.yaml | 3 ++ helm/oncall/templates/engine/deployment.yaml | 3 ++ .../telegram-polling/deployment.yaml | 3 ++ helm/oncall/tests/podlabels_test.yaml | 32 +++++++++++++++++++ helm/oncall/values.yaml | 9 ++++++ 5 files changed, 50 insertions(+) create mode 100644 helm/oncall/tests/podlabels_test.yaml diff --git a/helm/oncall/templates/celery/deployment.yaml b/helm/oncall/templates/celery/deployment.yaml index 32b4245c..b2498dd1 100644 --- a/helm/oncall/templates/celery/deployment.yaml +++ b/helm/oncall/templates/celery/deployment.yaml @@ -18,6 +18,9 @@ spec: {{- end }} labels: {{- include "oncall.celery.selectorLabels" . | nindent 8 }} + {{- if .Values.celery.podLabels }} + {{- toYaml .Values.celery.podLabels | nindent 8}} + {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/helm/oncall/templates/engine/deployment.yaml b/helm/oncall/templates/engine/deployment.yaml index e94df2ba..ccb770df 100644 --- a/helm/oncall/templates/engine/deployment.yaml +++ b/helm/oncall/templates/engine/deployment.yaml @@ -20,6 +20,9 @@ spec: {{- end }} labels: {{- include "oncall.engine.selectorLabels" . | nindent 8 }} + {{- if .Values.engine.podLabels }} + {{- toYaml .Values.engine.podLabels | nindent 8}} + {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/helm/oncall/templates/telegram-polling/deployment.yaml b/helm/oncall/templates/telegram-polling/deployment.yaml index acf90c97..2e448897 100644 --- a/helm/oncall/templates/telegram-polling/deployment.yaml +++ b/helm/oncall/templates/telegram-polling/deployment.yaml @@ -14,6 +14,9 @@ spec: metadata: labels: {{- include "oncall.telegramPolling.selectorLabels" . | nindent 8 }} + {{- if .Values.telegramPolling.podLabels }} + {{- toYaml .Values.telegramPolling.podLabels | nindent 8 }} + {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/helm/oncall/tests/podlabels_test.yaml b/helm/oncall/tests/podlabels_test.yaml new file mode 100644 index 00000000..d19dfd80 --- /dev/null +++ b/helm/oncall/tests/podlabels_test.yaml @@ -0,0 +1,32 @@ +suite: test podlabels for deployments +templates: + - celery/deployment.yaml + - engine/deployment.yaml + - telegram-polling/deployment.yaml +release: + name: oncall +tests: + - it: podLabels={} -> should exclude podLabels + set: + telegramPolling: + enabled: true + asserts: + - notExists: + path: spec.template.metadata.labels.some-key + + - it: podLabels -> should use custom podLabels + set: + engine: + podLabels: + some-key: some-value + celery: + podLabels: + some-key: some-value + telegramPolling: + enabled: true + podLabels: + some-key: some-value + asserts: + - equal: + path: spec.template.metadata.labels.some-key + value: some-value diff --git a/helm/oncall/values.yaml b/helm/oncall/values.yaml index 29f715f1..b741b1a4 100644 --- a/helm/oncall/values.yaml +++ b/helm/oncall/values.yaml @@ -39,6 +39,9 @@ engine: # cpu: 100m # memory: 128Mi + # Labels for engine pods + podLabels: {} + ## Deployment update strategy ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy updateStrategy: @@ -198,6 +201,9 @@ celery: # cpu: 100m # memory: 128Mi + # Labels for celery pods + podLabels: {} + ## Affinity for pod assignment ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity affinity: {} @@ -257,6 +263,9 @@ telegramPolling: # cpu: 100m # memory: 128Mi + # Labels for telegram-polling pods + podLabels: {} + # Extra volume mounts for the main container extraVolumeMounts: [] # - name: postgres-tls