Working with NFS CSI drivers
Follow the procedures in this section to install, configure, or delete the CSI drivers
that are required to use an NFS file share on an Amazon S3 File Gateway for storage in your
Kubernetes cluster. For more information, see the open-source NFS CSI driver
documentation on GitHub at
https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/docs/install-csi-driver-master.md
Install drivers
To install Kubernetes NFS CSI drivers:
-
From a command-line terminal with access to
kubectlfor your Kubernetes cluster, run the following command:curl -skSL https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/install-driver.sh | bash -s master --
-
Wait for the previous command to finish, then use the following commands to ensure that the CSI driver pods are running:
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
The output should look similar to the following:
NAME READY STATUS RESTARTS AGE IP NODE csi-nfs-controller-56bfddd689-dh5tk 4/4 Running 0 35s 10.240.0.19 k8s-agentpool-22533604-0 csi-nfs-controller-56bfddd689-8pgr4 4/4 Running 0 35s 10.240.0.35 k8s-agentpool-22533604-1 csi-nfs-node-cvgbs 3/3 Running 0 35s 10.240.0.35 k8s-agentpool-22533604-1 csi-nfs-node-dr4s4 3/3 Running 0 35s 10.240.0.4 k8s-agentpool-22533604-0
Create an NFS StorageClass object
To create an NFS StorageClass object for your Kubernetes cluster:
-
Create a configuration file named
storageclass.yamlwith contents that are similar to the following example. Substitute your own deployment-specific information for theExampleValuesshown.--- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name:example-nfs-classnamenamespace:example-namespaceprovisioner: nfs.csi.k8s.io parameters: server:gateway-dns-name-or-ip-addressshare:/example-share-namereclaimPolicy: Retain volumeBindingMode: Immediate mountOptions: - hard - nfsvers=4.1 -
From a command-line terminal with access to
kubectlandstorageclass.yaml, run the following command:kubectl apply -f storageclass.yaml
Note
You can also create the StorageClass by providing the
.yamlconfiguration text from the previous step to most third-party Kubernetes management and containerization platforms. -
Configure the pods in your Kubernetes cluster to use the new StorageClass object that you created. For more information, refer to the Kubernetes online documentation at https://kubernetes.io/docs/concepts/storage/
.
Create NFS PersistentVolume and PersistentVolumeClaim objects
To create new NFS PersistentVolume and PersistentVolumeClaim objects:
-
Create two configuration files named
persistentvolume.yamlandpersistentvolumeclaim.yaml. -
For
persistentvolume.yaml, add contents that are similar to the following example. Substitute your own deployment-specific information for theExampleValuesshown.--- apiVersion: v1 kind: PersistentVolume metadata: name:pv-nfs-examplenamespec: capacity: storage: 10Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain mountOptions: - hard - nolock - nfsvers=4.1 csi: driver: nfs.csi.k8s.io readOnly: false volumeHandle:unique-volumeid-example# make sure it's a unique id in the cluster volumeAttributes: server:gateway-dns-name-or-ip-addressshare:/example-share-name -
For
persistentvolumeclaim.yaml, add contents that are similar to the following example. Substitute your own deployment-specific information for theExampleValuesshown.--- kind: PersistentVolumeClaim apiVersion: v1 metadata: name:examplename-pvc-nfs-staticspec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi volumeName:pv-nfs-examplename# make sure specfied volumeName matches the name of the PersistentVolume you created storageClassName: "" -
From a command-line terminal with access to
kubectland both.yamlfiles, run the following commands:kubectl apply -f persistentvolume.yaml
kubectl apply -f persistentvolumeclaim.yaml
Note
You can also create the PersistentVolume and PersistentVolumeClaim objects by providing the
.yamlconfiguration text from the previous step to most third-party Kubernetes management and containerization platforms. -
Configure the pods in your Kubernetes cluster to use the new PersistentVolumeClaim object that you created. For more information, refer to the Kubernetes online documentation at https://kubernetes.io/docs/concepts/storage/
.
Uninstall drivers
To uninstall Kubernetes NFS CSI drivers:
-
From a command-line terminal with access to
kubectlfor your Kubernetes cluster, run the following command:curl -skSL https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/uninstall-driver.sh | bash -s master --