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 <copilot@github.com>
This commit is contained in:
2026-09-04 11:05:29 +02:00
co-authored by Copilot
parent 150c08eabc
commit 55964679ea
6 changed files with 125 additions and 31 deletions
+15 -14
View File
@@ -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
+10 -8
View File
@@ -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 }}
+5
View File
@@ -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 -}}
+34
View File
@@ -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:
@@ -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
+17 -9
View File
@@ -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: