helm: add an option to allow NFS mount soft fail
pipeline / build-and-push-images (push) Failing after 29s
pipeline / lint-and-publish-chart (push) Has been skipped

This commit is contained in:
2026-07-09 16:13:48 +02:00
parent 3c692adc9b
commit 357601574b
4 changed files with 41 additions and 3 deletions
+32 -1
View File
@@ -26,6 +26,30 @@ spec:
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}
containers: containers:
{{- if and .Values.nfs.enabled .Values.nfs.softFail }}
- name: nfs-mounter
image: alpine:3.20
securityContext:
capabilities:
add:
- SYS_ADMIN
command:
- /bin/sh
- -c
- |
apk add --no-cache nfs-utils 2>/dev/null || { echo "Cannot install nfs-utils, skipping NFS mount."; exec sleep infinity; }
echo "Attempting NFS mount {{ .Values.nfs.server }}:{{ .Values.nfs.path }}..."
if timeout 30 mount -t nfs -o timeo=10,soft,retrans=2 {{ .Values.nfs.server }}:{{ .Values.nfs.path }} /mnt/shared; then
echo "NFS mounted successfully. Files are served directly from NFS."
else
echo "NFS mount failed or timed out, continuing with empty directory."
fi
exec sleep infinity
volumeMounts:
- name: public-files
mountPath: /mnt/shared
mountPropagation: Bidirectional
{{- end }}
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
securityContext: securityContext:
{{- toYaml .Values.securityContext | nindent 12 }} {{- toYaml .Values.securityContext | nindent 12 }}
@@ -58,12 +82,19 @@ spec:
volumeMounts: volumeMounts:
- name: public-files - name: public-files
mountPath: {{ .Values.nfs.mountPath }} mountPath: {{ .Values.nfs.mountPath }}
{{- if .Values.nfs.softFail }}
mountPropagation: HostToContainer
{{- end }}
{{- end }} {{- end }}
{{- if .Values.nfs.enabled }} {{- if and .Values.nfs.enabled (not .Values.nfs.softFail) }}
volumes: volumes:
- name: public-files - name: public-files
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ include "vhaudiquet-fr.fullname" . }}-public claimName: {{ include "vhaudiquet-fr.fullname" . }}-public
{{- else if and .Values.nfs.enabled .Values.nfs.softFail }}
volumes:
- name: public-files
emptyDir: {}
{{- end }} {{- end }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
+1 -1
View File
@@ -1,4 +1,4 @@
{{- if .Values.nfs.enabled -}} {{- if and .Values.nfs.enabled (not .Values.nfs.softFail) -}}
apiVersion: v1 apiVersion: v1
kind: PersistentVolume kind: PersistentVolume
metadata: metadata:
+1 -1
View File
@@ -1,4 +1,4 @@
{{- if .Values.nfs.enabled -}} {{- if and .Values.nfs.enabled (not .Values.nfs.softFail) -}}
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
metadata: metadata:
+7
View File
@@ -104,3 +104,10 @@ nfs:
storageSize: 10Gi storageSize: 10Gi
# Storage class name (leave empty for default) # Storage class name (leave empty for default)
storageClassName: "" storageClassName: ""
# When true, use a sidecar container with mount propagation instead of PV/PVC
# so the pod can still start if the NFS server is unreachable. The sidecar
# will attempt to mount NFS directly into the shared volume; if it fails the
# app runs with an empty public directory. Files are served directly from NFS
# (no copying), making this suitable for large volumes.
# Requires: SYS_ADMIN capability on the sidecar, mountPropagation support.
softFail: false