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 }}
|
||||
{{- end }}
|
||||
{{- if .Values.nfs.enabled }}
|
||||
{{- 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:
|
||||
|
||||
Reference in New Issue
Block a user