Mount file systems as NFS on EKS or any K8’s. Below test is from EKS
My usecase, where I have to mount existing FS in readOnly mode on kubernetes
curl -skSL https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/install-driver.sh | bash -s master --
kubectl -n kube-system get pod -o wide -l app=csi-nfs-controller
kubectl -n kube-system get pod -o wide -l app=csi-nfs-node
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
pv.kubernetes.io/provisioned-by: nfs.csi.k8s.io
name: nfs-pv-server1
spec:
capacity:
storage: 1Gi # Placeholder; ignored for NFS
accessModes:
- ReadOnlyMany
mountOptions:
- nfsvers=4.1
persistentVolumeReclaimPolicy: Retain
csi:
driver: nfs.csi.k8s.io
volumeHandle: nfs-server1
volumeAttributes:
server: 0.0.0.0
share: /test/server1
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc-server1
namespace: xxx
spec:
accessModes:
- ReadOnlyMany
storageClassName: ""
resources:
requests:
storage: 1Gi # Placeholder; ignored for NFS
volumeName: nfs-pv-server1
---
apiVersion: v1
kind: Pod
metadata:
name: test-nfs-pod
namespace: xxx
spec:
containers:
- name: nfs-container
image: busybox
command:
- "sh"
- "-c"
- "ls /test/server1 && sleep 3600"
volumeMounts:
- name: nfs-server1
mountPath: "/test/server1"
readOnly: true
volumes:
- name: nfs-server1
persistentVolumeClaim:
claimName: nfs-pvc-server1
kubectl exec --stdin --tty test-nfs-pod -n xxx -- df -h
Filesystem Size Used Available Use% Mounted on
overlay 300.0G 16.5G 283.5G 5% /
tmpfs 64.0M 0 64.0M 0% /dev
tmpfs 15.3G 0 15.3G 0% /sys/fs/cgroup
0.0.0.0:/test/server1
427.0T 404.7T 23.2T 95% /test/server1
/dev/nvme0n1p1 300.0G 16.5G 283.5G 5% /etc/hosts
/dev/nvme0n1p1 300.0G 16.5G 283.5G 5% /dev/termination-log
/dev/nvme0n1p1 300.0G 16.5G 283.5G 5% /etc/hostname
/dev/nvme0n1p1 300.0G 16.5G 283.5G 5% /etc/resolv.conf
shm 64.0M 0 64.0M 0% /dev/shm
tmpfs 29.6G 12.0K 29.6G 0% /var/run/secrets/kubernetes.io/serviceaccount
tmpfs 15.3G 0 15.3G 0% /proc/acpi
tmpfs 64.0M 0 64.0M 0% /proc/kcore
tmpfs 64.0M 0 64.0M 0% /proc/keys
tmpfs 64.0M 0 64.0M 0% /proc/latency_stats
tmpfs 64.0M 0 64.0M 0% /proc/timer_list
tmpfs 64.0M 0 64.0M 0% /proc/sched_debug
tmpfs 15.3G 0 15.3G 0% /sys/firmware