From 150c08eabc7bfd841bef7f4c4e3d3118b4a0b09a Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 4 Sep 2026 09:12:58 +0200 Subject: [PATCH] feat(deployment)!: move `affinity` to `deployment.affinity` Moving `affinity` into the `deployment` dict groups it with the other Deployment-specific values and prepares a consistent structure for further migrations of pod-level settings. A deprecation check is added so that existing installations fail fast with an actionable error message instead of silently dropping the affinity rules, which would otherwise lead to pods being scheduled on unintended nodes. BREAKING CHANGE: `affinity` no longer exists. Use `deployment.affinity` instead. Installations that still set `affinity` will fail unless `checkDeprecation` is set to `false`. Co-authored-by: Copilot --- README.md | 4 ++-- templates/gitea/deployment.yaml | 2 +- templates/gitea/deprecation.yaml | 5 +++++ unittests/helm/deployment/basic.yaml | 29 ++++++++++++++++++++++++++++ values.yaml | 26 ++++++++++++++++++++----- 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8c8100d..0331f4c 100644 --- a/README.md +++ b/README.md @@ -1127,10 +1127,10 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo | `schedulerName` | Use an alternate scheduler, e.g. "stork" | `""` | | `nodeSelector` | NodeSelector for the deployment | `{}` | | `tolerations` | Tolerations for the deployment | `[]` | -| `affinity` | Affinity for the deployment | `{}` | | `topologySpreadConstraints` | TopologySpreadConstraints for the deployment | `[]` | | `dnsConfig` | dnsConfig for the deployment | `{}` | | `priorityClassName` | priorityClassName for the deployment | `""` | +| `deployment.affinity` | Affinity for the deployment. | `{}` | | `deployment.env` | Additional environment variables to pass to containers | `[]` | | `deployment.terminationGracePeriodSeconds` | How long to wait until forcefully kill the pod | `60` | | `deployment.labels` | Labels for the deployment | `{}` | @@ -1151,7 +1151,7 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo | `secrets.admin.new.annotations` | Annotations for the admin Secret | `{}` | | `secrets.admin.new.labels` | Labels for the admin Secret | `{}` | | `secrets.admin.new.email` | Email of the Gitea admin user | `gitea@local.domain` | -| `secrets.admin.new.password` | Password of the Gitea admin user | `r8sA8CPHD9!bt6d` | +| `secrets.admin.new.password` | Password of the Gitea admin user. | `r8sA8CPHD9!bt6d` | | `secrets.admin.new.username` | Username of the Gitea admin user | `gitea_admin` | | `secrets.config.addSHASumAnnotation` | Add a pod annotation with the SHA sum of the config Secret to trigger a rollout on change | `true` | | `secrets.config.existingSecret.enabled` | Use an already existing Secret instead of creating the config Secret | `false` | diff --git a/templates/gitea/deployment.yaml b/templates/gitea/deployment.yaml index c601435..cd0a2c1 100644 --- a/templates/gitea/deployment.yaml +++ b/templates/gitea/deployment.yaml @@ -426,7 +426,7 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} + {{- with .Values.deployment.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} diff --git a/templates/gitea/deprecation.yaml b/templates/gitea/deprecation.yaml index dbef4ae..c24a4ca 100644 --- a/templates/gitea/deprecation.yaml +++ b/templates/gitea/deprecation.yaml @@ -39,4 +39,9 @@ {{- if .Values.signing -}} {{- fail "`signing` does no longer exist. Please refer to the changelog and configure `secrets.gpg` instead." -}} {{- end -}} + + {{/* AFFINITY */}} + {{- if .Values.affinity -}} + {{- fail "`affinity` does no longer exist. Please refer to the changelog and configure `deployment.affinity` instead." -}} + {{- end -}} {{- end -}} diff --git a/unittests/helm/deployment/basic.yaml b/unittests/helm/deployment/basic.yaml index eda85ab..cf60063 100644 --- a/unittests/helm/deployment/basic.yaml +++ b/unittests/helm/deployment/basic.yaml @@ -67,6 +67,35 @@ tests: foo: bar bar: foo template: templates/gitea/deployment.yaml + - it: affinity is undefined + template: templates/gitea/deployment.yaml + asserts: + - notExists: + path: spec.template.spec.affinity + - it: affinity is defined + template: templates/gitea/deployment.yaml + set: + deployment.affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/os + operator: In + values: + - linux + asserts: + - equal: + path: spec.template.spec.affinity + value: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/os + operator: In + values: + - linux - it: "injects TMP_EXISTING_ENVS_FILE as environment variable to 'init-app-ini' init container" template: templates/gitea/deployment.yaml diff --git a/values.yaml b/values.yaml index 1798c4f..e10cfb2 100644 --- a/values.yaml +++ b/values.yaml @@ -319,9 +319,6 @@ nodeSelector: {} ## @param tolerations Tolerations for the deployment tolerations: [] -## @param affinity Affinity for the deployment -affinity: {} - ## @param topologySpreadConstraints TopologySpreadConstraints for the deployment topologySpreadConstraints: [] @@ -331,11 +328,30 @@ dnsConfig: {} ## @param priorityClassName priorityClassName for the deployment priorityClassName: "" -## @param deployment.env Additional environment variables to pass to containers +## @param deployment.affinity Affinity for the deployment. +## @param deployment.env Additional environment variables to pass to containers ## @param deployment.terminationGracePeriodSeconds How long to wait until forcefully kill the pod ## @param deployment.labels Labels for the deployment ## @param deployment.annotations Annotations for the Gitea deployment to be created deployment: + affinity: {} + # nodeAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # nodeSelectorTerms: + # - matchExpressions: + # - key: kubernetes.io/os + # operator: In + # values: + # - linux + # preferredDuringSchedulingIgnoredDuringExecution: + # - weight: 20 + # preference: + # matchExpressions: + # - key: kubernetes.io/arch + # operator: In + # values: + # - amd64 + env: [] # - name: VARIABLE # value: my-value @@ -370,7 +386,7 @@ secrets: ## @param secrets.admin.new.annotations Annotations for the admin Secret ## @param secrets.admin.new.labels Labels for the admin Secret ## @param secrets.admin.new.email Email of the Gitea admin user - ## @param secrets.admin.new.password Password of the Gitea admin user + ## @param secrets.admin.new.password Password of the Gitea admin user. ## @param secrets.admin.new.username Username of the Gitea admin user new: annotations: {}