[Kubernetes (K8S)] Helm install nfs-client-provisioner within Kubernetes (K8S)
helm-nfs-server-provisioner-example
NFS Server Provisioner
The NFS client provisioner - https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client is an automatic provisioner for Kubernetes that uses your already configured NFS server, automatically creating Persistent Volumes.
This chart will deploy the Kubernetes nfs provisioner. This provisioner is intended for connecting to a pre-existing NFS server, and not includes a built in NFS server. If you want a built in NFS Server, please consider using the nfs-client-provisioner - https://github.com/helm/charts/tree/master/stable/nfs-client-provisioner instead.
This article is about how to use Helm to install nfs-client-provisioner on Kubernetes (K8S).
As of Nov 13, 2020, charts in this repo will no longer be updated. For more information, see the Helm Charts Deprecation and Archive Notice, and Update.
You can use Azure Helm mirror - http://mirror.azure.cn/kubernetes/charts/ to replace https://kubernetes-charts.storage.googleapis.com
Prerequisites
-
Kubernetes (K8S)
Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications. -
Helm
Helm is the best way to find, share, and use software built for Kubernetes. -
NFS packages and rpcbind.service
A Network File System (NFS) allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally.The rpcbind service uses TCP wrappers for access control, and access control rules for rpcbind affect all RPC-based services(Such as NFS).
1
2
3
4
5
6
7
8
9CentOS
Install NFS utils.
sudo yum install nfs-utils -y
Start and enable rpcbind.service
sudo systemctl start rpcbind && sudo systemctl enable rpcbind
Start and enable rpc-statd.service
sudo systemctl start rpc-statd && sudo systemctl enable rpc-statd -
Pre-existing NFS server
You must have a pre-existing NFS server installed according to NFS Server and Client Installation on CentOS 7 - https://www.howtoforge.com/nfs-server-and-client-on-centos-7, or use which is provided by the third-party vendors(such as [5] File Storage NAS: Reliable Network Attached Storage - Alibaba Cloud - https://www.alibabacloud.com/product/nas).
Install
Helm install nfs-client-provisioner into nfs-client-provisioner or your other namespace.
1 | crate namespace: |
See Helm release about nfs-client-provisioner
1 | helm list --namespace nfs-client-provisioner |
See pods about nfs-client-provisioner.
1 | kubectl get pods -n nfs-client-provisioner |
Custom Values.yaml
Edit values.yaml and replace content within {{ }}
.
1 | # values.yaml |
Then, check the StorageClass status.
1 | kubectl get sc |
Dynamically Provision PersistentVolume
Since v1.9. Users now can and should instead use the storageClassName
field of the PersistentVolumeClaim
object. The value of this field must match the name of a StorageClass configured by the administrator (see below).
To select the “fast” storage class, for example, a user would create the following PersistentVolumeClaim:
1 | # nfs-client-pvc.yaml |
Check pvc.
1 | kubectl get pvc |
The following is a example about nfs-server-provisioner dynamically provision a PersistentVolume to the Deployment.
1 | # nginx-deployment.yaml |
Apply nginx-deployment.yaml to create the Deployment.
1 | kubectl apply -f nginx-deploymentyaml |
Check Nginx Deployment.
1 | kubectl get pods |
Then, the Pod of the Deployment will mount a Volume from nfs-client-provisioner.
rpcbind service not start
if the nfs packages is not install or rpcbind.service
is not started, the Pod can not mount pv with error(such as
Unable to attach or mount volumes: unmounted volumes=[storage], unattached volumes=[config storage nginx-deployment-token-fr5t7]: timed out waiting for the condition) .
You need to install nfs packages, then start and enable rpcbind.service
.
Uninstalling the Chart
To uninstall/delete the my-release deployment:
1 | helm delete nfs-client-provisioner |
The command removes all the Kubernetes components associated with the chart and deletes the release.