From 55964679ea4ef16d1984330790b6eac1ad7b56e5 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 4 Sep 2026 11:05:29 +0200 Subject: [PATCH] feat(deployment)!: move `deployment.env` to `deployment.gitea.env` and add `deployment.enabled` The `deployment` dict mixes values that apply to the Deployment object itself (`annotations`, `labels`, `affinity`, `terminationGracePeriodSeconds`) with values that apply to a single container. `deployment.env` was the only container-scoped key, which made it unclear which container it targets once further containers get their own configuration. Grouping container-scoped values under `deployment.gitea` establishes a per-container namespace and leaves room for sibling sections without another breaking rename later. The value ordering in `values.yaml` is aligned with the chart conventions (`enabled`, `annotations`, `labels` first). `deployment.enabled` is introduced and wired up in the template so the Deployment can be skipped entirely. This allows the chart to be used for rendering only the surrounding resources, e.g. when the workload itself is managed elsewhere. A deprecation check is added so that existing installations fail fast with an actionable error message instead of silently dropping their environment variables, which would otherwise surface as hard-to-debug runtime misconfiguration. Unit tests cover the disabled Deployment, the propagation of `deployment.gitea.env` into all init containers and the Gitea container, and the deprecation checks for `affinity` and `deployment.env`. BREAKING CHANGE: `deployment.env` no longer exists. Use `deployment.gitea.env` instead. Installations that still set `deployment.env` will fail unless `checkDeprecation` is set to `false`. Co-authored-by: Copilot --- README.md | 29 +++++++------- templates/gitea/deployment.yaml | 18 +++++---- templates/gitea/deprecation.yaml | 5 +++ unittests/helm/deployment/basic.yaml | 34 ++++++++++++++++ unittests/helm/deployment/deprecations.yaml | 44 +++++++++++++++++++++ values.yaml | 26 +++++++----- 6 files changed, 125 insertions(+), 31 deletions(-) create mode 100644 unittests/helm/deployment/deprecations.yaml diff --git a/README.md b/README.md index 0331f4c..75e1e09 100644 --- a/README.md +++ b/README.md @@ -1121,20 +1121,21 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo ### deployment -| Name | Description | Value | -| ------------------------------------------ | ------------------------------------------------------ | ----- | -| `resources` | Kubernetes resources | `{}` | -| `schedulerName` | Use an alternate scheduler, e.g. "stork" | `""` | -| `nodeSelector` | NodeSelector for the deployment | `{}` | -| `tolerations` | Tolerations 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 | `{}` | -| `deployment.annotations` | Annotations for the Gitea deployment to be created | `{}` | +| Name | Description | Value | +| ------------------------------------------ | ---------------------------------------------------------------- | ------ | +| `resources` | Kubernetes resources | `{}` | +| `schedulerName` | Use an alternate scheduler, e.g. "stork" | `""` | +| `nodeSelector` | NodeSelector for the deployment | `{}` | +| `tolerations` | Tolerations for the deployment | `[]` | +| `topologySpreadConstraints` | TopologySpreadConstraints for the deployment | `[]` | +| `dnsConfig` | dnsConfig for the deployment | `{}` | +| `priorityClassName` | priorityClassName 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 | `{}` | +| `deployment.affinity` | Affinity for the deployment. | `{}` | +| `deployment.terminationGracePeriodSeconds` | How long to wait until forcefully kill the pod | `60` | +| `deployment.gitea.env` | Additional environment variables to pass to the Gitea container. | `[]` | ### Secret diff --git a/templates/gitea/deployment.yaml b/templates/gitea/deployment.yaml index cd0a2c1..ba870c9 100644 --- a/templates/gitea/deployment.yaml +++ b/templates/gitea/deployment.yaml @@ -1,3 +1,4 @@ +{{- if .Values.deployment.enabled -}} apiVersion: apps/v1 kind: Deployment metadata: @@ -100,8 +101,8 @@ spec: value: /data - name: GITEA_TEMP value: /tmp/gitea - {{- if .Values.deployment.env }} - {{- toYaml .Values.deployment.env | nindent 12 }} + {{- if .Values.deployment.gitea.env }} + {{- toYaml .Values.deployment.gitea.env | nindent 12 }} {{- end }} {{- if .Values.secrets.gpg.enabled }} - name: GNUPGHOME @@ -153,8 +154,8 @@ spec: value: /tmp/existing-envs - name: ENV_TO_INI_MOUNT_POINT value: /env-to-ini-mounts - {{- if .Values.deployment.env }} - {{- toYaml .Values.deployment.env | nindent 12 }} + {{- if .Values.deployment.gitea.env }} + {{- toYaml .Values.deployment.gitea.env | nindent 12 }} {{- end }} {{- if .Values.gitea.additionalConfigFromEnvs }} {{- tpl (toYaml .Values.gitea.additionalConfigFromEnvs) $ | nindent 12 }} @@ -311,8 +312,8 @@ spec: - name: GITEA_ADMIN_PASSWORD_MODE value: {{ include "gitea.secret.admin.passwordMode" $ }} {{- end }} - {{- if .Values.deployment.env }} - {{- toYaml .Values.deployment.env | nindent 12 }} + {{- if .Values.deployment.gitea.env }} + {{- toYaml .Values.deployment.gitea.env | nindent 12 }} {{- end }} volumeMounts: - name: init @@ -373,8 +374,8 @@ spec: name: {{ include "gitea.secret.gpg.name" . }} key: {{ include "gitea.secret.gpg.gpgHomeKey" . }} {{- end }} - {{- if .Values.deployment.env }} - {{- toYaml .Values.deployment.env | nindent 12 }} + {{- if .Values.deployment.gitea.env }} + {{- toYaml .Values.deployment.gitea.env | nindent 12 }} {{- end }} ports: - name: ssh @@ -482,3 +483,4 @@ spec: - name: data emptyDir: {} {{- end }} +{{- end }} diff --git a/templates/gitea/deprecation.yaml b/templates/gitea/deprecation.yaml index c24a4ca..5d4b5ac 100644 --- a/templates/gitea/deprecation.yaml +++ b/templates/gitea/deprecation.yaml @@ -44,4 +44,9 @@ {{- if .Values.affinity -}} {{- fail "`affinity` does no longer exist. Please refer to the changelog and configure `deployment.affinity` instead." -}} {{- end -}} + + {{/* DEPLOYMENT ENV */}} + {{- if .Values.deployment.env -}} + {{- fail "`deployment.env` does no longer exist. Please refer to the changelog and configure `deployment.gitea.env` instead." -}} + {{- end -}} {{- end -}} diff --git a/unittests/helm/deployment/basic.yaml b/unittests/helm/deployment/basic.yaml index cf60063..1d2205b 100644 --- a/unittests/helm/deployment/basic.yaml +++ b/unittests/helm/deployment/basic.yaml @@ -20,6 +20,13 @@ tests: kind: Deployment apiVersion: apps/v1 name: gitea-unittests + - it: renders no deployment when disabled + template: templates/gitea/deployment.yaml + set: + deployment.enabled: false + asserts: + - hasDocuments: + count: 0 - it: deployment labels are set template: templates/gitea/deployment.yaml set: @@ -113,6 +120,33 @@ tests: content: name: ENV_TO_INI_MOUNT_POINT value: /env-to-ini-mounts + - it: "deployment.gitea.env is injected into all init containers and the gitea container" + template: templates/gitea/deployment.yaml + set: + deployment.gitea.env: + - name: VARIABLE + value: my-value + asserts: + - contains: + path: spec.template.spec.initContainers[0].env + content: + name: VARIABLE + value: my-value + - contains: + path: spec.template.spec.initContainers[1].env + content: + name: VARIABLE + value: my-value + - contains: + path: spec.template.spec.initContainers[2].env + content: + name: VARIABLE + value: my-value + - contains: + path: spec.template.spec.containers[0].env + content: + name: VARIABLE + value: my-value - it: CPU resources are defined as well as GOMAXPROCS template: templates/gitea/deployment.yaml set: diff --git a/unittests/helm/deployment/deprecations.yaml b/unittests/helm/deployment/deprecations.yaml new file mode 100644 index 0000000..29606a7 --- /dev/null +++ b/unittests/helm/deployment/deprecations.yaml @@ -0,0 +1,44 @@ +suite: deprecation template (deployment) +release: + name: gitea-unittests + namespace: testing +templates: + - templates/gitea/deprecation.yaml +tests: + - it: renders nothing with the default values + asserts: + - hasDocuments: + count: 0 + - it: fails when the removed `affinity` value is set + set: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/os + operator: In + values: + - linux + asserts: + - failedTemplate: + errorMessage: "`affinity` does no longer exist. Please refer to the changelog and configure `deployment.affinity` instead." + - it: fails when the removed `deployment.env` value is set + set: + deployment.env: + - name: VARIABLE + value: my-value + asserts: + - failedTemplate: + errorMessage: "`deployment.env` does no longer exist. Please refer to the changelog and configure `deployment.gitea.env` instead." + - it: skips the deprecation checks when `checkDeprecation` is disabled + set: + checkDeprecation: false + affinity: + nodeAffinity: {} + deployment.env: + - name: VARIABLE + value: my-value + asserts: + - hasDocuments: + count: 0 diff --git a/values.yaml b/values.yaml index e10cfb2..c133b06 100644 --- a/values.yaml +++ b/values.yaml @@ -328,12 +328,17 @@ dnsConfig: {} ## @param priorityClassName priorityClassName for the deployment priorityClassName: "" -## @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.enabled Enable the deployment of Gitea. ## @param deployment.annotations Annotations for the Gitea deployment to be created +## @param deployment.labels Labels for the deployment +## @param deployment.affinity Affinity for the deployment. +## @param deployment.terminationGracePeriodSeconds How long to wait until forcefully kill the pod + deployment: + enabled: true + annotations: {} + labels: {} + affinity: {} # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: @@ -352,12 +357,15 @@ deployment: # values: # - amd64 - env: [] - # - name: VARIABLE - # value: my-value + + gitea: + ## @param deployment.gitea.env Additional environment variables to pass to the gitea container. + env: [] + # - name: VARIABLE + # value: my-value + terminationGracePeriodSeconds: 60 - labels: {} - annotations: {} + ## @section Secret secrets: