From 0d7368c5d086d7b8954233ea66ee62f11c24b5d2 Mon Sep 17 00:00:00 2001 From: Tarun Gaba Date: Thu, 22 Jan 2026 21:36:10 +0000 Subject: [PATCH] fix(deployment): remove deployment.labels from selector.matchLabels (#1011) This PR removes the inclusion of `deployment.labels` in the Deployment's `selector.matchLabels` field. ## Changes - Removed the conditional block that adds `deployment.labels` to `selector.matchLabels` - This ensures the selector remains immutable and only contains pod-identifying labels Reviewed-on: https://gitea.com/gitea/helm-gitea/pulls/1011 Reviewed-by: Markus Pesch Co-authored-by: Tarun Gaba Co-committed-by: Tarun Gaba --- templates/gitea/deployment.yaml | 3 --- unittests/helm/deployment/basic.yaml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/templates/gitea/deployment.yaml b/templates/gitea/deployment.yaml index 7da7d29..8871323 100644 --- a/templates/gitea/deployment.yaml +++ b/templates/gitea/deployment.yaml @@ -24,9 +24,6 @@ spec: selector: matchLabels: {{- include "gitea.selectorLabels" . | nindent 6 }} - {{- if .Values.deployment.labels }} - {{- toYaml .Values.deployment.labels | nindent 6 }} - {{- end }} template: metadata: annotations: diff --git a/unittests/helm/deployment/basic.yaml b/unittests/helm/deployment/basic.yaml index 1c81294..003cf2e 100644 --- a/unittests/helm/deployment/basic.yaml +++ b/unittests/helm/deployment/basic.yaml @@ -29,6 +29,22 @@ tests: path: spec.template.metadata.labels content: hello: world + - isNotSubset: + path: spec.selector.matchLabels + content: + hello: world + - it: deployment labels are not in selector matchLabels + template: templates/gitea/deployment.yaml + set: + deployment.labels: + custom-label: custom-value + another-label: another-value + asserts: + - equal: + path: spec.selector.matchLabels + value: + app.kubernetes.io/name: gitea + app.kubernetes.io/instance: gitea-unittests - it: nodeSelector is undefined asserts: - notExists: