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>
305 lines
10 KiB
Smarty
305 lines
10 KiB
Smarty
{{/* initDirectories */}}
|
|
|
|
{{- define "gitea.initContainer.initDirectories" -}}
|
|
{{- $config := .Values.deployment.initDirectories -}}
|
|
- name: init-directories
|
|
image: "{{ include "gitea.image.name" (list . $config.image) }}"
|
|
imagePullPolicy: {{ $config.image.pullPolicy }}
|
|
command:
|
|
- "{{ .Values.initContainersScriptsVolumeMountPath }}/init_directory_structure.sh"
|
|
env:
|
|
- name: GITEA_APP_INI
|
|
value: /data/gitea/conf/app.ini
|
|
- name: GITEA_CUSTOM
|
|
value: /data/gitea
|
|
- name: GITEA_WORK_DIR
|
|
value: /data
|
|
- name: GITEA_TEMP
|
|
value: /tmp/gitea
|
|
{{- if .Values.deployment.gitea.env }}
|
|
{{- toYaml .Values.deployment.gitea.env | nindent 4 }}
|
|
{{- end }}
|
|
{{- if .Values.secrets.gpg.enabled }}
|
|
- name: GNUPGHOME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "gitea.secret.gpg.name" . }}
|
|
key: {{ include "gitea.secret.gpg.gpgHomeKey" . }}
|
|
{{- end }}
|
|
{{- with $config.env }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
{{- with $config.envFrom }}
|
|
envFrom:
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: init
|
|
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
|
|
- name: temp
|
|
mountPath: /tmp
|
|
- name: data
|
|
mountPath: /data
|
|
{{- if .Values.persistence.new.subPath }}
|
|
subPath: {{ .Values.persistence.new.subPath }}
|
|
{{- end }}
|
|
{{- include "gitea.init-additional-mounts" . | nindent 4 }}
|
|
{{- with $config.volumeMounts }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
{{- with (include "gitea.containerSecurityContext" (list . (deepCopy ($config.securityContext | default .Values.deployment.gitea.securityContext))) | trim) }}
|
|
securityContext:
|
|
{{- . | nindent 4 }}
|
|
{{- end }}
|
|
resources:
|
|
{{- toYaml ($config.resources | default .Values.initContainers.resources) | nindent 4 }}
|
|
{{- end }}
|
|
|
|
{{/* initAppIni */}}
|
|
|
|
{{- define "gitea.initContainer.initAppIni" -}}
|
|
{{- $config := .Values.deployment.initAppIni -}}
|
|
- name: init-app-ini
|
|
image: "{{ include "gitea.image.name" (list . $config.image) }}"
|
|
imagePullPolicy: {{ $config.image.pullPolicy }}
|
|
{{- if .Values.gitea.extraEnvSourceFile }}
|
|
command:
|
|
- "/bin/bash"
|
|
- "-c"
|
|
args:
|
|
- "test -f {{ .Values.gitea.extraEnvSourceFile }} && source {{ .Values.gitea.extraEnvSourceFile }} || { echo 'ERROR: Failed to source {{ .Values.gitea.extraEnvSourceFile }}'; exit 1; } && {{ .Values.initContainersScriptsVolumeMountPath }}/config_environment.sh"
|
|
{{- else }}
|
|
command:
|
|
- "{{ .Values.initContainersScriptsVolumeMountPath }}/config_environment.sh"
|
|
{{- end }}
|
|
env:
|
|
- name: GITEA_APP_INI
|
|
value: /data/gitea/conf/app.ini
|
|
- name: GITEA_CUSTOM
|
|
value: /data/gitea
|
|
- name: GITEA_WORK_DIR
|
|
value: /data
|
|
- name: GITEA_TEMP
|
|
value: /tmp/gitea
|
|
- name: TMP_EXISTING_ENVS_FILE
|
|
value: /tmp/existing-envs
|
|
- name: ENV_TO_INI_MOUNT_POINT
|
|
value: /env-to-ini-mounts
|
|
{{- if .Values.deployment.gitea.env }}
|
|
{{- toYaml .Values.deployment.gitea.env | nindent 4 }}
|
|
{{- end }}
|
|
{{- if .Values.gitea.additionalConfigFromEnvs }}
|
|
{{- tpl (toYaml .Values.gitea.additionalConfigFromEnvs) $ | nindent 4 }}
|
|
{{- end }}
|
|
{{- with $config.env }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
{{- with $config.envFrom }}
|
|
envFrom:
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: config
|
|
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
|
|
- name: temp
|
|
mountPath: /tmp
|
|
- name: data
|
|
mountPath: /data
|
|
{{- if .Values.persistence.new.subPath }}
|
|
subPath: {{ .Values.persistence.new.subPath }}
|
|
{{- end }}
|
|
- name: inline-config-sources
|
|
mountPath: /env-to-ini-mounts/inlines/
|
|
{{- range $idx, $value := .Values.gitea.additionalConfigSources }}
|
|
- name: additional-config-sources-{{ $idx }}
|
|
mountPath: "/env-to-ini-mounts/additionals/{{ $idx }}/"
|
|
{{- end }}
|
|
{{- include "gitea.init-additional-mounts" . | nindent 4 }}
|
|
{{- with $config.volumeMounts }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
{{- with (include "gitea.containerSecurityContext" (list . (deepCopy ($config.securityContext | default .Values.deployment.gitea.securityContext))) | trim) }}
|
|
securityContext:
|
|
{{- . | nindent 4 }}
|
|
{{- end }}
|
|
resources:
|
|
{{- toYaml ($config.resources | default .Values.initContainers.resources) | nindent 4 }}
|
|
{{- end }}
|
|
|
|
{{/* initConfigureGPG */}}
|
|
|
|
{{- define "gitea.initContainer.initConfigureGPG" -}}
|
|
{{- $config := .Values.deployment.initConfigureGPG -}}
|
|
{{- if .Values.secrets.gpg.enabled -}}
|
|
- name: configure-gpg
|
|
image: "{{ include "gitea.image.name" (list . $config.image) }}"
|
|
{{- if .Values.gitea.extraEnvSourceFile }}
|
|
command:
|
|
- "/bin/bash"
|
|
- "-c"
|
|
args:
|
|
- "test -f {{ .Values.gitea.extraEnvSourceFile }} && source {{ .Values.gitea.extraEnvSourceFile }} || { echo 'ERROR: Failed to source {{ .Values.gitea.extraEnvSourceFile }}'; exit 1; } && {{ .Values.initContainersScriptsVolumeMountPath }}/configure_gpg_environment.sh"
|
|
{{- else }}
|
|
command:
|
|
- "{{ .Values.initContainersScriptsVolumeMountPath }}/configure_gpg_environment.sh"
|
|
{{- end }}
|
|
imagePullPolicy: {{ $config.image.pullPolicy }}
|
|
{{- with (include "gitea.commandInitContainerSecurityContext" (list . (deepCopy ($config.securityContext | default .Values.deployment.gitea.securityContext))) | trim) }}
|
|
securityContext:
|
|
{{- . | nindent 4 }}
|
|
{{- end }}
|
|
env:
|
|
- name: GNUPGHOME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "gitea.secret.gpg.name" . }}
|
|
key: {{ include "gitea.secret.gpg.gpgHomeKey" . }}
|
|
- name: TMP_RAW_GPG_KEY
|
|
value: /raw/private.asc
|
|
{{- with $config.env }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
{{- with $config.envFrom }}
|
|
envFrom:
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: init
|
|
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
|
|
- name: data
|
|
mountPath: /data
|
|
{{- if .Values.persistence.new.subPath }}
|
|
subPath: {{ .Values.persistence.new.subPath }}
|
|
{{- end }}
|
|
- name: gpg-private-key
|
|
mountPath: /raw
|
|
readOnly: true
|
|
{{- if .Values.extraVolumeMounts }}
|
|
{{- toYaml .Values.extraVolumeMounts | nindent 4 }}
|
|
{{- end }}
|
|
{{- with $config.volumeMounts }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
resources:
|
|
{{- toYaml ($config.resources | default .Values.initContainers.resources) | nindent 4 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{/* initConfigureGitea */}}
|
|
|
|
{{- define "gitea.initContainer.initConfigureGitea" -}}
|
|
{{- $config := .Values.deployment.initConfigureGitea -}}
|
|
- name: configure-gitea
|
|
image: "{{ include "gitea.image.name" (list . $config.image) }}"
|
|
{{- if .Values.gitea.extraEnvSourceFile }}
|
|
command:
|
|
- "/bin/bash"
|
|
- "-c"
|
|
args:
|
|
- "test -f {{ .Values.gitea.extraEnvSourceFile }} && source {{ .Values.gitea.extraEnvSourceFile }} || { echo 'ERROR: Failed to source {{ .Values.gitea.extraEnvSourceFile }}'; exit 1; } && {{ .Values.initContainersScriptsVolumeMountPath }}/configure_gitea.sh"
|
|
{{- else }}
|
|
command:
|
|
- "{{ .Values.initContainersScriptsVolumeMountPath }}/configure_gitea.sh"
|
|
{{- end }}
|
|
imagePullPolicy: {{ $config.image.pullPolicy }}
|
|
{{- with (include "gitea.commandInitContainerSecurityContext" (list . (deepCopy ($config.securityContext | default .Values.deployment.gitea.securityContext))) | trim) }}
|
|
securityContext:
|
|
{{- . | nindent 4 }}
|
|
{{- end }}
|
|
env:
|
|
- name: GITEA_APP_INI
|
|
value: /data/gitea/conf/app.ini
|
|
- name: GITEA_CUSTOM
|
|
value: /data/gitea
|
|
- name: GITEA_WORK_DIR
|
|
value: /data
|
|
- name: GITEA_TEMP
|
|
value: /tmp/gitea
|
|
{{- if $config.image.rootless }}
|
|
- name: HOME
|
|
value: /data/gitea/git
|
|
{{- end }}
|
|
{{- if .Values.gitea.ldap }}
|
|
{{- range $idx, $value := .Values.gitea.ldap }}
|
|
{{- if $value.existingSecret }}
|
|
- name: GITEA_LDAP_BIND_DN_{{ $idx }}
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: bindDn
|
|
name: {{ $value.existingSecret }}
|
|
- name: GITEA_LDAP_PASSWORD_{{ $idx }}
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: bindPassword
|
|
name: {{ $value.existingSecret }}
|
|
{{- else }}
|
|
- name: GITEA_LDAP_BIND_DN_{{ $idx }}
|
|
value: {{ $value.bindDn | quote }}
|
|
- name: GITEA_LDAP_PASSWORD_{{ $idx }}
|
|
value: {{ $value.bindPassword | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if .Values.gitea.oauth }}
|
|
{{- range $idx, $value := .Values.gitea.oauth }}
|
|
{{- if $value.existingSecret }}
|
|
- name: GITEA_OAUTH_KEY_{{ $idx }}
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: key
|
|
name: {{ $value.existingSecret }}
|
|
- name: GITEA_OAUTH_SECRET_{{ $idx }}
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: secret
|
|
name: {{ $value.existingSecret }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if .Values.secrets.admin.enabled }}
|
|
- name: GITEA_ADMIN_USERNAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: {{ include "gitea.secret.admin.usernameKey" . }}
|
|
name: {{ include "gitea.secret.admin.name" . }}
|
|
- name: GITEA_ADMIN_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: {{ include "gitea.secret.admin.passwordKey" . }}
|
|
name: {{ include "gitea.secret.admin.name" . }}
|
|
- name: GITEA_ADMIN_EMAIL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: {{ include "gitea.secret.admin.emailKey" . }}
|
|
name: {{ include "gitea.secret.admin.name" . }}
|
|
- name: GITEA_ADMIN_PASSWORD_MODE
|
|
value: {{ include "gitea.secret.admin.passwordMode" $ }}
|
|
{{- end }}
|
|
{{- if .Values.deployment.gitea.env }}
|
|
{{- toYaml .Values.deployment.gitea.env | nindent 4 }}
|
|
{{- end }}
|
|
{{- with $config.env }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
{{- with $config.envFrom }}
|
|
envFrom:
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: init
|
|
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
|
|
- name: temp
|
|
mountPath: /tmp
|
|
- name: data
|
|
mountPath: /data
|
|
{{- if .Values.persistence.new.subPath }}
|
|
subPath: {{ .Values.persistence.new.subPath }}
|
|
{{- end }}
|
|
{{- include "gitea.init-additional-mounts" . | nindent 4 }}
|
|
{{- with $config.volumeMounts }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
resources:
|
|
{{- toYaml ($config.resources | default .Values.initContainers.resources) | nindent 4 }}
|
|
{{- end }}
|