From 9e12eeccab2bc54391da5bd80e04e521c3b13d32 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 4 Sep 2026 11:52:17 +0200 Subject: [PATCH] feat(deployment)!: move `topologySpreadConstraints` to `deployment.topologySpreadConstraints` The top-level `topologySpreadConstraints` value only ever configured the pod spec of the Gitea Deployment, yet it lived next to chart-wide settings. This made it hard to tell which values influence the Deployment and which apply to the chart as a whole. Moving it into the `deployment` dict continues the consolidation already done for `affinity`, `dnsConfig`, `nodeSelector`, `priorityClassName` and `resources`, so all pod scheduling settings are now grouped in one predictable place. A deprecation check fails the release when the removed top-level value is still set. Silently ignoring it would be particularly harmful here: the constraints would be dropped without any warning and all replicas could end up scheduled on a single node or zone, defeating the availability guarantees the user configured. BREAKING CHANGE: `topologySpreadConstraints` no longer exists. Use `deployment.topologySpreadConstraints` instead. Installations that still set `topologySpreadConstraints` will fail unless `checkDeprecation` is set to `false`. Co-authored-by: Copilot --- README.md | 6 ++--- templates/gitea/deployment.yaml | 2 +- templates/gitea/deprecation.yaml | 5 +++++ unittests/helm/deployment/basic.yaml | 25 +++++++++++++++++++++ unittests/helm/deployment/deprecations.yaml | 9 ++++++++ values.yaml | 10 ++++++--- 6 files changed, 50 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 10f8ae7..2268b17 100644 --- a/README.md +++ b/README.md @@ -1118,14 +1118,13 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo | `gatewayAPI.nginx.clientSettingsPolicies.labels` | Additional labels applied to the ClientSettingsPolicy | `{}` | | `gatewayAPI.nginx.clientSettingsPolicies.targetRef` | Target reference for the ClientSettingsPolicy. Defaults to the chart's HTTPRoute. | `{}` | | `gatewayAPI.nginx.clientSettingsPolicies.body` | Client body settings (required when enabled), e.g. `maxSize`. See `docs/gateway-api.md`. | `{}` | +| `schedulerName` | Use an alternate scheduler, e.g. "stork" | `""` | +| `tolerations` | Tolerations for the deployment | `[]` | ### deployment | Name | Description | Value | | ------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------ | -| `schedulerName` | Use an alternate scheduler, e.g. "stork" | `""` | -| `tolerations` | Tolerations for the deployment | `[]` | -| `topologySpreadConstraints` | TopologySpreadConstraints for the deployment | `[]` | | `deployment.enabled` | Enable the deployment of Gitea. | `true` | | `deployment.annotations` | Annotations for the Gitea deployment to be created | `{}` | | `deployment.labels` | Labels for the deployment | `{}` | @@ -1137,6 +1136,7 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo | `deployment.priorityClassName` | priorityClassName for the deployment | `""` | | `deployment.resources` | Resources is the total amount of CPU and Memory resources required by all containers in the pod. | `{}` | | `deployment.terminationGracePeriodSeconds` | How long to wait until forcefully kill the pod | `60` | +| `deployment.topologySpreadConstraints` | TopologySpreadConstraints for the deployment | `[]` | ### Secret diff --git a/templates/gitea/deployment.yaml b/templates/gitea/deployment.yaml index e6288de..9280c9e 100644 --- a/templates/gitea/deployment.yaml +++ b/templates/gitea/deployment.yaml @@ -433,7 +433,7 @@ spec: affinity: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.topologySpreadConstraints }} + {{- with .Values.deployment.topologySpreadConstraints }} topologySpreadConstraints: {{- toYaml . | nindent 8 }} {{- end }} diff --git a/templates/gitea/deprecation.yaml b/templates/gitea/deprecation.yaml index 92b82e6..29b5fa1 100644 --- a/templates/gitea/deprecation.yaml +++ b/templates/gitea/deprecation.yaml @@ -69,4 +69,9 @@ {{- if .Values.resources -}} {{- fail "`resources` does no longer exist. Please refer to the changelog and configure `deployment.gitea.resources` instead." -}} {{- end -}} + + {{/* TOPOLOGY SPREAD CONSTRAINTS */}} + {{- if .Values.topologySpreadConstraints -}} + {{- fail "`topologySpreadConstraints` does no longer exist. Please refer to the changelog and configure `deployment.topologySpreadConstraints` instead." -}} + {{- end -}} {{- end -}} diff --git a/unittests/helm/deployment/basic.yaml b/unittests/helm/deployment/basic.yaml index 1f9a3de..5190945 100644 --- a/unittests/helm/deployment/basic.yaml +++ b/unittests/helm/deployment/basic.yaml @@ -139,6 +139,31 @@ tests: - equal: path: spec.template.spec.priorityClassName value: high-priority + - it: topologySpreadConstraints are undefined + template: templates/gitea/deployment.yaml + asserts: + - notExists: + path: spec.template.spec.topologySpreadConstraints + - it: topologySpreadConstraints are defined + template: templates/gitea/deployment.yaml + set: + deployment.topologySpreadConstraints: + - topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + maxSkew: 1 + labelSelector: + matchLabels: + app.kubernetes.io/instance: gitea-unittests + asserts: + - equal: + path: spec.template.spec.topologySpreadConstraints + value: + - topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + maxSkew: 1 + labelSelector: + matchLabels: + app.kubernetes.io/instance: gitea-unittests - it: "injects TMP_EXISTING_ENVS_FILE as environment variable to 'init-app-ini' init container" template: templates/gitea/deployment.yaml diff --git a/unittests/helm/deployment/deprecations.yaml b/unittests/helm/deployment/deprecations.yaml index 187cd51..62407b9 100644 --- a/unittests/helm/deployment/deprecations.yaml +++ b/unittests/helm/deployment/deprecations.yaml @@ -60,6 +60,13 @@ tests: asserts: - failedTemplate: errorMessage: "`resources` does no longer exist. Please refer to the changelog and configure `deployment.gitea.resources` instead." + - it: fails when the removed `topologySpreadConstraints` value is set + set: + topologySpreadConstraints: + - topologyKey: kubernetes.io/hostname + asserts: + - failedTemplate: + errorMessage: "`topologySpreadConstraints` does no longer exist. Please refer to the changelog and configure `deployment.topologySpreadConstraints` instead." - it: skips the deprecation checks when `checkDeprecation` is disabled set: checkDeprecation: false @@ -77,6 +84,8 @@ tests: resources: limits: cpu: 100m + topologySpreadConstraints: + - topologyKey: kubernetes.io/hostname asserts: - hasDocuments: count: 0 diff --git a/values.yaml b/values.yaml index 4dc05c5..3d2fb35 100644 --- a/values.yaml +++ b/values.yaml @@ -302,9 +302,6 @@ schedulerName: "" ## @param tolerations Tolerations for the deployment tolerations: [] -## @param topologySpreadConstraints TopologySpreadConstraints for the deployment -topologySpreadConstraints: [] - ## @section deployment deployment: ## @param deployment.enabled Enable the deployment of Gitea. @@ -390,6 +387,13 @@ deployment: ## @param deployment.terminationGracePeriodSeconds How long to wait until forcefully kill the pod terminationGracePeriodSeconds: 60 + ## @param deployment.topologySpreadConstraints TopologySpreadConstraints for the deployment + topologySpreadConstraints: [] + # - topologyKey: kubernetes.io/hostname + # whenUnsatisfiable: DoNotSchedule + # labelSelector: + # matchLabels: + # app.kubernetes.io/instance: athens-proxy ## @section Secret secrets: