refactor(persistence)!: group the values into existingPersistentVolumeClaim and new
Helm / helm-lint (push) Successful in 13s
changelog / changelog (push) Successful in 22s
Helm / helm-unittest (push) Failing after 45s
Markdown linter / markdown-link-checker (push) Successful in 44s
Markdown linter / markdown-lint (push) Successful in 36s

The flat `persistence` dict mixed three concerns: whether persistence is used at all, whether the chart creates the
PersistentVolumeClaim, and how that claim is shaped. The pairs `create`/`claimName` and `enabled`/`mount` were only
meaningful in certain combinations, so an invalid configuration such as `create=true` together with a foreign
`claimName` was silently accepted. The same split into an `existingX`/`new` pair is already used for the Secrets, so
this aligns persistence with the rest of the chart.

`persistence.enabled` now only decides whether a volume is used at all. `persistence.existingPersistentVolumeClaim`
points at a claim managed outside of the chart, and everything under `persistence.new` describes the claim the chart
creates itself. Rendering and naming move into `templates/gitea/_persistentVolumeClaims.tpl` so the Deployment and the
PersistentVolumeClaim derive the claim name from a single helper instead of repeating the value lookups.

Support for `global.storageClass` is dropped. It was a chart-wide override that silently applied to the Gitea claim and
was evaluated through `tpl`, which made the effective storage class hard to predict. The storage class is now set
explicitly via `persistence.new.storageClassName`, which also matches the field name in the PersistentVolumeClaim spec.

BREAKING CHANGE: The `persistence` values were restructured and `global.storageClass` was removed.

- `persistence.create` and `persistence.mount` are gone. Set `persistence.enabled` to use a volume and
  `persistence.existingPersistentVolumeClaim.enabled` to reuse a claim that is not managed by the chart.
- `persistence.claimName` moves to `persistence.existingPersistentVolumeClaim.persistentVolumeClaimName`. A claim
  created by the chart is now named after `gitea.fullname` instead of the default `gitea-shared-storage`.
- `persistence.accessModes`, `annotations`, `labels`, `size` and `subPath` move into `persistence.new`.
- `persistence.volumeName` becomes `persistence.new.persistentVolumeName`.
- `persistence.storageClass` and `global.storageClass` become `persistence.new.storageClassName`.
- `persistence.enabled` now defaults to `false`.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-09-14 15:38:06 +02:00
co-authored by Copilot
parent 761921faed
commit dfe087c0c1
12 changed files with 160 additions and 139 deletions
+15 -17
View File
@@ -1023,7 +1023,6 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| ------------------------- | -------------------------------------------------------------------------- | ----- | | ------------------------- | -------------------------------------------------------------------------- | ----- |
| `global.imageRegistry` | global image registry override. | `""` | | `global.imageRegistry` | global image registry override. | `""` |
| `global.imagePullSecrets` | global image pull secrets override; can be extended by `imagePullSecrets`. | `[]` | | `global.imagePullSecrets` | global image pull secrets override; can be extended by `imagePullSecrets`. | `[]` |
| `global.storageClass` | global storage class override. | `""` |
| `global.hostAliases` | global hostAliases which will be added to the pod's hosts files. | `[]` | | `global.hostAliases` | global hostAliases which will be added to the pod's hosts files. | `[]` |
### deployment ### deployment
@@ -1287,22 +1286,21 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
### Persistence ### Persistence
| Name | Description | Value | | Name | Description | Value |
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------- | | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------- |
| `persistence.enabled` | Enable persistent storage. | `true` | | `persistence.enabled` | Enable persistent storage. | `false` |
| `persistence.create` | Whether to create the persistentVolumeClaim for shared storage. | `true` | | `persistence.existingPersistentVolumeClaim.enabled` | Enable using an existing persistent volume claim. | `false` |
| `persistence.mount` | Whether the persistentVolumeClaim should be mounted (even if not created). | `true` | | `persistence.existingPersistentVolumeClaim.persistentVolumeClaimName` | Name of the existing persistent volume claim to use. | `""` |
| `persistence.claimName` | Use an existing claim to store repository information. | `gitea-shared-storage` | | `persistence.new.annotations.helm.sh/resource-policy` | Resource policy for the new persistent volume claim. | `keep` |
| `persistence.size` | Size for persistence to store repo information. | `10Gi` | | `persistence.new.labels` | Labels for the new persistent volume claim. | `{}` |
| `persistence.accessModes` | AccessMode for persistence. | `["ReadWriteOnce"]` | | `persistence.new.accessModes` | AccessMode for the new persistent volume claim. | `["ReadWriteOnce"]` |
| `persistence.labels` | Labels for the persistence volume claim to be created. | `{}` | | `persistence.new.persistentVolumeName` | Name of the persistent volume for the new persistent volume claim. | `""` |
| `persistence.annotations.helm.sh/resource-policy` | Resource policy for the persistence volume claim. | `keep` | | `persistence.new.size` | Size for the new persistent volume claim. | `10Gi` |
| `persistence.storageClass` | Name of the storage class to use. | `nil` | | `persistence.new.storageClassName` | Name of the storage class to use for the new persistent volume claim. | `""` |
| `persistence.subPath` | Subdirectory of the volume to mount at. | `nil` | | `persistence.new.subPath` | Subdirectory of the volume to mount at for the new persistent volume claim. | `""` |
| `persistence.volumeName` | Name of persistent volume in PVC. | `""` | | `extraContainers` | Additional sidecar containers to run in the pod. | `[]` |
| `extraContainers` | Additional sidecar containers to run in the pod. | `[]` | | `extraInitVolumeMounts` | Mounts that are only mapped into the init-containers. Can be used for additional preconfiguration. | `[]` |
| `extraInitVolumeMounts` | Mounts that are only mapped into the init-containers. Can be used for additional preconfiguration. | `[]` | | `extraVolumeMounts` | **DEPRECATED** Additional volume mounts for init containers and the Gitea main container. | `[]` |
| `extraVolumeMounts` | **DEPRECATED** Additional volume mounts for init containers and the Gitea main container. | `[]` |
### Init ### Init
-11
View File
@@ -154,17 +154,6 @@ These default to runAsUser 1000 outside OpenShift to preserve existing behavior.
{{- include "gitea.containerSecurityContext" (list $root $containerSecurityContext) -}} {{- include "gitea.containerSecurityContext" (list $root $containerSecurityContext) -}}
{{- end -}} {{- end -}}
{{/*
Storage Class
*/}}
{{- define "gitea.persistence.storageClass" -}}
{{- $storageClass := (tpl ( default "" .Values.persistence.storageClass) .) | default (tpl ( default "" .Values.global.storageClass) .) }}
{{- if $storageClass }}
storageClassName: {{ $storageClass | quote }}
{{- end }}
{{- end -}}
{{/* {{/*
Common labels Common labels
*/}} */}}
+8 -8
View File
@@ -40,8 +40,8 @@
mountPath: /tmp mountPath: /tmp
- name: data - name: data
mountPath: /data mountPath: /data
{{- if .Values.persistence.subPath }} {{- if .Values.persistence.new.subPath }}
subPath: {{ .Values.persistence.subPath }} subPath: {{ .Values.persistence.new.subPath }}
{{- end }} {{- end }}
{{- include "gitea.init-additional-mounts" . | nindent 4 }} {{- include "gitea.init-additional-mounts" . | nindent 4 }}
{{- with $config.volumeMounts }} {{- with $config.volumeMounts }}
@@ -105,8 +105,8 @@
mountPath: /tmp mountPath: /tmp
- name: data - name: data
mountPath: /data mountPath: /data
{{- if .Values.persistence.subPath }} {{- if .Values.persistence.new.subPath }}
subPath: {{ .Values.persistence.subPath }} subPath: {{ .Values.persistence.new.subPath }}
{{- end }} {{- end }}
- name: inline-config-sources - name: inline-config-sources
mountPath: /env-to-ini-mounts/inlines/ mountPath: /env-to-ini-mounts/inlines/
@@ -168,8 +168,8 @@
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }} mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
- name: data - name: data
mountPath: /data mountPath: /data
{{- if .Values.persistence.subPath }} {{- if .Values.persistence.new.subPath }}
subPath: {{ .Values.persistence.subPath }} subPath: {{ .Values.persistence.new.subPath }}
{{- end }} {{- end }}
- name: gpg-private-key - name: gpg-private-key
mountPath: /raw mountPath: /raw
@@ -292,8 +292,8 @@
mountPath: /tmp mountPath: /tmp
- name: data - name: data
mountPath: /data mountPath: /data
{{- if .Values.persistence.subPath }} {{- if .Values.persistence.new.subPath }}
subPath: {{ .Values.persistence.subPath }} subPath: {{ .Values.persistence.new.subPath }}
{{- end }} {{- end }}
{{- include "gitea.init-additional-mounts" . | nindent 4 }} {{- include "gitea.init-additional-mounts" . | nindent 4 }}
{{- with $config.volumeMounts }} {{- with $config.volumeMounts }}
@@ -0,0 +1,38 @@
{{/* vim: set filetype=mustache: */}}
{{/* annotations */}}
{{- define "gitea.persistentVolumeClaim.annotations" -}}
{{- with .Values.persistence.new.annotations }}
{{- toYaml . -}}
{{- end }}
{{- end }}
{{/* enabled */}}
{{- define "gitea.persistentVolumeClaim.enabled" -}}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingPersistentVolumeClaim.enabled) -}}
true
{{- else -}}
false
{{- end }}
{{- end }}
{{/* labels */}}
{{- define "gitea.persistentVolumeClaim.labels" -}}
{{ include "gitea.labels" . }}
{{- with .Values.persistence.new.labels }}
{{ toYaml . }}
{{- end }}
{{- end }}
{{/* name */}}
{{- define "gitea.persistentVolumeClaim.name" -}}
{{- if .Values.persistence.existingPersistentVolumeClaim.enabled -}}
{{ required "persistence.existingPersistentVolumeClaim.persistentVolumeClaimName is required when persistence.existingPersistentVolumeClaim.enabled is true" .Values.persistence.existingPersistentVolumeClaim.persistentVolumeClaimName }}
{{- else -}}
{{ include "gitea.fullname" . }}
{{- end }}
{{- end }}
+4 -6
View File
@@ -145,8 +145,8 @@ spec:
mountPath: /tmp mountPath: /tmp
- name: data - name: data
mountPath: /data mountPath: /data
{{- if .Values.persistence.subPath }} {{- if .Values.persistence.new.subPath }}
subPath: {{ .Values.persistence.subPath }} subPath: {{ .Values.persistence.new.subPath }}
{{- end }} {{- end }}
{{- include "gitea.container-additional-mounts" . | nindent 12 }} {{- include "gitea.container-additional-mounts" . | nindent 12 }}
{{- if .Values.extraContainers }} {{- if .Values.extraContainers }}
@@ -211,12 +211,10 @@ spec:
defaultMode: 0100 defaultMode: 0100
{{- end }} {{- end }}
{{- if .Values.persistence.enabled }} {{- if .Values.persistence.enabled }}
{{- if .Values.persistence.mount }}
- name: data - name: data
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ .Values.persistence.claimName }} claimName: {{ include "gitea.persistentVolumeClaim.name" . }}
{{- end }} {{- else }}
{{- else if not .Values.persistence.enabled }}
- name: data - name: data
emptyDir: {} emptyDir: {}
{{- end }} {{- end }}
+20 -13
View File
@@ -1,26 +1,33 @@
{{- if and .Values.persistence.enabled .Values.persistence.create }} {{- if eq (include "gitea.persistentVolumeClaim.enabled" .) "true" }}
---
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: {{ .Values.persistence.claimName }} {{- with (include "gitea.persistentVolumeClaim.annotations" .) }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
annotations: annotations:
{{ .Values.persistence.annotations | toYaml | indent 4}} {{- . | nindent 4 }}
{{- end }}
{{- with (include "gitea.persistentVolumeClaim.labels" .) }}
labels: labels:
{{ .Values.persistence.labels | toYaml | indent 4}} {{- . | nindent 4 }}
{{- end }}
name: {{ include "gitea.persistentVolumeClaim.name" . }}
namespace: {{ .Release.Namespace }}
spec: spec:
accessModes: accessModes:
{{- if gt (.Values.deployment.replicas | int) 1 }} {{- if gt (.Values.deployment.replicas | int) 1 }}
- ReadWriteMany - ReadWriteMany
{{- else }} {{- else }}
{{- .Values.persistence.accessModes | toYaml | nindent 4 }} {{- .Values.persistence.new.accessModes | toYaml | nindent 4 }}
{{- end }}
volumeMode: Filesystem
{{- include "gitea.persistence.storageClass" . | nindent 2 }}
{{- with .Values.persistence.volumeName }}
volumeName: {{ . }}
{{- end }} {{- end }}
resources: resources:
requests: requests:
storage: {{ .Values.persistence.size }} storage: {{ .Values.persistence.new.size }}
{{- end }} {{- with .Values.persistence.new.storageClassName }}
storageClassName: {{ . }}
{{- end }}
volumeMode: Filesystem
{{- with .Values.persistence.new.persistentVolumeName }}
volumeName: {{ . }}
{{- end }}
{{- end }}
+2 -2
View File
@@ -37,8 +37,8 @@ stringData:
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if eq (first .Values.persistence.accessModes) "ReadWriteOnce" -}} {{- if eq (first .Values.persistence.new.accessModes) "ReadWriteOnce" -}}
{{- fail "When using multiple replicas, a RWX file system is required and persistence.accessModes[0] must be set to ReadWriteMany." -}} {{- fail "When using multiple replicas, a RWX file system is required and persistence.new.accessModes[0] must be set to ReadWriteMany." -}}
{{- end }} {{- end }}
{{- if .Values.gitea.config.indexer -}} {{- if .Values.gitea.config.indexer -}}
{{- if eq .Values.gitea.config.indexer.ISSUE_INDEXER_TYPE "bleve" -}} {{- if eq .Values.gitea.config.indexer.ISSUE_INDEXER_TYPE "bleve" -}}
+10 -7
View File
@@ -17,8 +17,9 @@ tests:
deployment: deployment:
replicas: 2 replicas: 2
persistence: persistence:
accessModes: new:
- ReadWriteMany accessModes:
- ReadWriteMany
gitea: gitea:
config: config:
cron: cron:
@@ -34,15 +35,16 @@ tests:
replicas: 2 replicas: 2
asserts: asserts:
- failedTemplate: - failedTemplate:
errorMessage: "When using multiple replicas, a RWX file system is required and persistence.accessModes[0] must be set to ReadWriteMany." errorMessage: "When using multiple replicas, a RWX file system is required and persistence.new.accessModes[0] must be set to ReadWriteMany."
- it: fails with multiple replicas and bleve issue indexer - it: fails with multiple replicas and bleve issue indexer
template: templates/gitea/secret_config.yaml template: templates/gitea/secret_config.yaml
set: set:
deployment: deployment:
replicas: 2 replicas: 2
persistence: persistence:
accessModes: new:
- ReadWriteMany accessModes:
- ReadWriteMany
gitea: gitea:
config: config:
indexer: indexer:
@@ -56,8 +58,9 @@ tests:
deployment: deployment:
replicas: 2 replicas: 2
persistence: persistence:
accessModes: new:
- ReadWriteMany accessModes:
- ReadWriteMany
gitea: gitea:
config: config:
indexer: indexer:
@@ -1,39 +1,17 @@
# File: tests/gitea-storageclass-tests.yaml chart:
appVersion: 1.27.3
suite: storage class configuration tests
release: release:
name: gitea-storageclass-tests name: gitea-unittests
namespace: testing namespace: testing
suite: Storage class configuration tests
templates: templates:
- templates/gitea/persistentVolumeClaim.yaml - templates/gitea/persistentVolumeClaim.yaml
tests: tests:
- it: should set storageClassName when persistence.storageClass is defined - it: Set storageClassName when persistence.new.storageClassName is defined
template: templates/gitea/persistentVolumeClaim.yaml
set: set:
persistence.storageClass: "my-storage-class" persistence.enabled: true
asserts: persistence.new.storageClassName: my-storage-class
- equal:
path: "spec.storageClassName"
value: "my-storage-class"
- it: should set global.storageClass when persistence.storageClass is not defined
template: templates/gitea/persistentVolumeClaim.yaml
set:
global.storageClass: "default-storage-class"
asserts: asserts:
- equal: - equal:
path: spec.storageClassName path: spec.storageClassName
value: "default-storage-class" value: my-storage-class
- it: should set storageClassName when persistence.storageClass is defined and global.storageClass is defined
template: templates/gitea/persistentVolumeClaim.yaml
set:
global.storageClass: "default-storage-class"
persistence.storageClass: "my-storage-class"
asserts:
- equal:
path: spec.storageClassName
value: "my-storage-class"
@@ -0,0 +1,29 @@
chart:
appVersion: 1.27.3 # renovate: datasource=docker registryUrl=https://docker.gitea.com depName=gitea
release:
name: gitea-unittests
namespace: testing
suite: PVC template
templates:
- templates/gitea/persistentVolumeClaim.yaml
tests:
- it: Skip persistentVolumeClaim if persistentVolumeClaim is disabled
set:
persistence.enabled: false
asserts:
- hasDocuments:
count: 0
- it: Render persistentVolumeClaim with default values
set:
persistence.enabled: true
persistence.new.storageClassName: "my-storage-class"
asserts:
- containsDocument:
apiVersion: v1
kind: PersistentVolumeClaim
name: gitea-unittests
namespace: testing
- equal:
path: spec.storageClassName
value: "my-storage-class"
-19
View File
@@ -1,19 +0,0 @@
suite: PVC template
release:
name: gitea-unittests
namespace: testing
templates:
- templates/gitea/persistentVolumeClaim.yaml
tests:
- it: Storage Class using TPL
set:
global.persistence.storageClass: "storage-class"
persistence.enabled: true
persistence.create: true
persistence.storageClass: "{{ .Values.global.persistence.storageClass }}"
asserts:
- isKind:
of: PersistentVolumeClaim
- equal:
path: spec.storageClassName
value: "storage-class"
+26 -26
View File
@@ -5,7 +5,6 @@
# #
## @param global.imageRegistry global image registry override. ## @param global.imageRegistry global image registry override.
## @param global.imagePullSecrets global image pull secrets override; can be extended by `imagePullSecrets`. ## @param global.imagePullSecrets global image pull secrets override; can be extended by `imagePullSecrets`.
## @param global.storageClass global storage class override.
## @param global.hostAliases global hostAliases which will be added to the pod's hosts files. ## @param global.hostAliases global hostAliases which will be added to the pod's hosts files.
global: global:
imageRegistry: "" imageRegistry: ""
@@ -14,7 +13,6 @@ global:
## - myRegistryKeySecretName ## - myRegistryKeySecretName
## ##
imagePullSecrets: [] imagePullSecrets: []
storageClass: ""
hostAliases: [] hostAliases: []
# - ip: 192.168.137.2 # - ip: 192.168.137.2
# hostnames: # hostnames:
@@ -887,31 +885,33 @@ serviceAccount:
labels: {} labels: {}
## @section Persistence ## @section Persistence
## @param persistence.enabled Enable persistent storage.
## @param persistence.create Whether to create the persistentVolumeClaim for shared storage.
## @param persistence.mount Whether the persistentVolumeClaim should be mounted (even if not created).
## @param persistence.claimName Use an existing claim to store repository information.
## @param persistence.size Size for persistence to store repo information.
## @param persistence.accessModes AccessMode for persistence.
## @param persistence.labels Labels for the persistence volume claim to be created.
## @param persistence.annotations.helm.sh/resource-policy Resource policy for the persistence volume claim.
## @param persistence.storageClass Name of the storage class to use.
## @param persistence.subPath Subdirectory of the volume to mount at.
## @param persistence.volumeName Name of persistent volume in PVC.
persistence: persistence:
enabled: true ## @param persistence.enabled Enable persistent storage.
create: true enabled: false
mount: true
claimName: gitea-shared-storage ## @param persistence.existingPersistentVolumeClaim.enabled Enable using an existing persistent volume claim.
size: 10Gi ## @param persistence.existingPersistentVolumeClaim.persistentVolumeClaimName Name of the existing persistent volume claim to use.
accessModes: existingPersistentVolumeClaim:
- ReadWriteOnce enabled: false
labels: {} persistentVolumeClaimName: ""
storageClass:
subPath: ## @param persistence.new.annotations.helm.sh/resource-policy Resource policy for the new persistent volume claim.
volumeName: "" ## @param persistence.new.labels Labels for the new persistent volume claim.
annotations: ## @param persistence.new.accessModes AccessMode for the new persistent volume claim.
helm.sh/resource-policy: keep ## @param persistence.new.persistentVolumeName Name of the persistent volume for the new persistent volume claim.
## @param persistence.new.size Size for the new persistent volume claim.
## @param persistence.new.storageClassName Name of the storage class to use for the new persistent volume claim.
## @param persistence.new.subPath Subdirectory of the volume to mount at for the new persistent volume claim.
new:
annotations:
helm.sh/resource-policy: keep
labels: {}
accessModes:
- ReadWriteOnce
persistentVolumeName: ""
size: 10Gi
storageClassName: ""
subPath: ""
## @param extraContainers Additional sidecar containers to run in the pod. ## @param extraContainers Additional sidecar containers to run in the pod.
extraContainers: [] extraContainers: []