helm: add an option to allow NFS mount soft fail
This commit is contained in:
@@ -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,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,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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user