feat: make it configurable of the initContainers volume mount path for scripts (#848)

### Description of the change

Makes it configurable volume mount path for initContainers for init scripts

### Benefits

Configurable initContainers volumeMount path for init scripts

### Possible drawbacks

I don't think that there will be any drawbacks

### Applicable issues

- Fixes #847

Signed-off-by: Batuhan Apaydin <batuhan.apaydin@chainguard.dev>

Reviewed-on: https://gitea.com/gitea/helm-gitea/pulls/848
Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.com>
Co-authored-by: developerguy <developerguy@noreply.gitea.com>
Co-committed-by: developerguy <developerguy@noreply.gitea.com>
This commit is contained in:
developerguy 2025-04-03 18:03:13 +00:00 committed by justusbunsi
parent fa36d2beef
commit a7035ca4e5
5 changed files with 43 additions and 16 deletions

View File

@ -1052,12 +1052,13 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
### Init
| Name | Description | Value |
| ------------------------------------------ | ------------------------------------------------------------------------------------ | ------- |
| `initPreScript` | Bash shell script copied verbatim to the start of the init-container. | `""` |
| `initContainers.resources.limits` | initContainers.limits Kubernetes resource limits for init containers | `{}` |
| `initContainers.resources.requests.cpu` | initContainers.requests.cpu Kubernetes cpu resource limits for init containers | `100m` |
| `initContainers.resources.requests.memory` | initContainers.requests.memory Kubernetes memory resource limits for init containers | `128Mi` |
| Name | Description | Value |
| ------------------------------------------ | ------------------------------------------------------------------------------------ | ------------ |
| `initPreScript` | Bash shell script copied verbatim to the start of the init-container. | `""` |
| `initContainersScriptsVolumeMountPath` | Path to mount the scripts consumed from the Secrets | `/usr/sbinx` |
| `initContainers.resources.limits` | initContainers.limits Kubernetes resource limits for init containers | `{}` |
| `initContainers.resources.requests.cpu` | initContainers.requests.cpu Kubernetes cpu resource limits for init containers | `100m` |
| `initContainers.resources.requests.memory` | initContainers.requests.memory Kubernetes memory resource limits for init containers | `128Mi` |
### Signing

View File

@ -62,7 +62,8 @@ spec:
- name: init-directories
image: "{{ include "gitea.image" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/usr/sbin/init_directory_structure.sh"]
command:
- "{{ .Values.initContainersScriptsVolumeMountPath }}/init_directory_structure.sh"
env:
- name: GITEA_APP_INI
value: /data/gitea/conf/app.ini
@ -81,7 +82,7 @@ spec:
{{- end }}
volumeMounts:
- name: init
mountPath: /usr/sbin
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
- name: temp
mountPath: /tmp
- name: data
@ -97,7 +98,8 @@ spec:
- name: init-app-ini
image: "{{ include "gitea.image" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/usr/sbin/config_environment.sh"]
command:
- "{{ .Values.initContainersScriptsVolumeMountPath }}/config_environment.sh"
env:
- name: GITEA_APP_INI
value: /data/gitea/conf/app.ini
@ -119,7 +121,7 @@ spec:
{{- end }}
volumeMounts:
- name: config
mountPath: /usr/sbin
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
- name: temp
mountPath: /tmp
- name: data
@ -141,7 +143,8 @@ spec:
{{- if .Values.signing.enabled }}
- name: configure-gpg
image: "{{ include "gitea.image" . }}"
command: ["/usr/sbin/configure_gpg_environment.sh"]
command:
- "{{ .Values.initContainersScriptsVolumeMountPath }}/configure_gpg_environment.sh"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
{{- /* By default this container runs as user 1000 unless otherwise stated */ -}}
@ -157,7 +160,7 @@ spec:
value: /raw/private.asc
volumeMounts:
- name: init
mountPath: /usr/sbin
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
- name: data
mountPath: /data
{{- if .Values.persistence.subPath }}
@ -174,7 +177,8 @@ spec:
{{- end }}
- name: configure-gitea
image: "{{ include "gitea.image" . }}"
command: ["/usr/sbin/configure_gitea.sh"]
command:
- "{{ .Values.initContainersScriptsVolumeMountPath }}/configure_gitea.sh"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
{{- /* By default this container runs as user 1000 unless otherwise stated */ -}}
@ -257,7 +261,7 @@ spec:
{{- end }}
volumeMounts:
- name: init
mountPath: /usr/sbin
mountPath: {{ .Values.initContainersScriptsVolumeMountPath }}
- name: temp
mountPath: /tmp
- name: data

View File

@ -73,3 +73,23 @@ tests:
requests:
cpu: 100ms
memory: 100Mi
- it: Init containers have correct volumeMount path
template: templates/gitea/deployment.yaml
set:
initContainersScriptsVolumeMountPath: "/custom/init/path"
asserts:
- equal:
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath
value: "/custom/init/path"
- equal:
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath
value: "/custom/init/path"
- it: Init containers have correct volumeMount path if there is no override
template: templates/gitea/deployment.yaml
asserts:
- equal:
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath
value: "/usr/sbinx"
- equal:
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath
value: "/usr/sbinx"

View File

@ -18,7 +18,7 @@ tests:
value: configure-gpg
- equal:
path: spec.template.spec.initContainers[2].command
value: ["/usr/sbin/configure_gpg_environment.sh"]
value: ["/usr/sbinx/configure_gpg_environment.sh"]
- equal:
path: spec.template.spec.initContainers[2].securityContext
value:
@ -34,7 +34,7 @@ tests:
path: spec.template.spec.initContainers[2].volumeMounts
value:
- name: init
mountPath: /usr/sbin
mountPath: /usr/sbinx
- name: data
mountPath: /data
- name: gpg-private-key

View File

@ -314,6 +314,8 @@ extraVolumeMounts: []
## @section Init
## @param initPreScript Bash shell script copied verbatim to the start of the init-container.
initPreScript: ""
## @param initContainersScriptsVolumeMountPath Path to mount the scripts consumed from the Secrets
initContainersScriptsVolumeMountPath: "/usr/sbinx"
#
# initPreScript: |
# mkdir -p /data/git/.postgresql