[Kubernetes (K8S)] Helm install nfs-server-provisioner within Kubernetes (K8S)
helm-nfs-server-provisioner-example
NFS Server Provisioner
nfs-client-provisioner - https://github.com/helm/charts/tree/master/stable/nfs-client-provisioner is an out-of-tree dynamic provisioner for Kubernetes. You can use it to quickly & easily deploy shared storage that works almost anywhere throught Network File System (NFS).
This chart will deploy the Kubernetes nfs provisioner. This provisioner includes a built in NFS server, and is not intended for connecting to a pre-existing NFS server. If you have a pre-existing 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-server-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
Install
Helm install nfs-server-provisioner into nfs-server-provisioner or your other namespace.
1 | crate namespace: |
See Helm release about nfs-server-provisioner
1 | helm list --namespace nfs-server-provisioner |
See pods about nfs-server-provisioner.
1 | kubectl get pods -n nfs-server-provisioner |
See StorageClass.
1 | kubectl get sc |
Custom Values.yaml
With others storage class.
On many clusters, the cloud provider integration will create a storage class which will create a volume (e.g. a Google Compute Engine Persistent Disk or Amazon EBS volume - gp) to provide persistence.
The following is a recommended configuration example when another storage class exists to provide persistence:
1 | # cat values.yaml |
Without others storage class.
The following is a recommended configration example for running on bare metal with a hostPath volume. Need to do:
- specify nodeSelector with Your Node Host Name or Label.
- create a Persistence Volume manually.
The following is a recommended configuration example when another storage class does not exist to provide persistence:
Edit values.yaml and replace content within < and >.
1 | # cat values.yaml |
In this configuration, a PersistentVolume must be created for each replica to use. Installing the Helm chart, and then inspecting the PersistentVolumeClaim’s created will provide the necessary names for your PersistentVolume’s to bind to.
Otherwise Pod nfs-server-provisioner-0 will fail with error pod has unbound immediate PersistentVolumeClaims.
An example of the necessary PersistentVolume:
1 | # pv.yaml |
Apply pv.yaml to creat a PersistentVolume.
1 | kubectl apply -f pv.yaml |
Then, check the PersistentVolume status.
1 | kubectl get pv data-nfs-server-provisioner-0 -o wide |
Dynamically Provision PersistentVolume
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-server-provisioner.
FAQs
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
.
1 | Start and enable rpcbind.service |
Either use ‘-o nolock’ to keep locks local, or start statd
If service rpc-statd
is not started, you will encounter this error:
1 | systemctl status |
Enable and start rpc-statd
to resolve it.
1 | Start and enable rpc-statd.service |
References
[3] Kubernetes - https://kubernetes.io/
[4] nfs-client-provisioner - https://github.com/helm/charts/tree/master/stable/nfs-client-provisioner