helm: add an option to allow NFS mount soft fail
This commit is contained in:
@@ -26,6 +26,30 @@ spec:
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
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 }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
@@ -58,12 +82,19 @@ spec:
|
||||
volumeMounts:
|
||||
- name: public-files
|
||||
mountPath: {{ .Values.nfs.mountPath }}
|
||||
{{- if .Values.nfs.softFail }}
|
||||
mountPropagation: HostToContainer
|
||||
{{- end }}
|
||||
{{- if .Values.nfs.enabled }}
|
||||
{{- end }}
|
||||
{{- if and .Values.nfs.enabled (not .Values.nfs.softFail) }}
|
||||
volumes:
|
||||
- name: public-files
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "vhaudiquet-fr.fullname" . }}-public
|
||||
{{- else if and .Values.nfs.enabled .Values.nfs.softFail }}
|
||||
volumes:
|
||||
- name: public-files
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if .Values.nfs.enabled -}}
|
||||
{{- if and .Values.nfs.enabled (not .Values.nfs.softFail) -}}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if .Values.nfs.enabled -}}
|
||||
{{- if and .Values.nfs.enabled (not .Values.nfs.softFail) -}}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
|
||||
@@ -104,3 +104,10 @@ nfs:
|
||||
storageSize: 10Gi
|
||||
# Storage class name (leave empty for default)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user