Uses your existing and already configured NFS server to support dynamic provisioning of Kubernetes Persistent Volumes via Persistent Volume Claims.
Start with cloning the external-storage GitHub repo on the master node:
https://github.com/kubernetes-incubator/external-storage
git clone https://github.com/kubernetes-incubator/external-storage
Navigate to the external-storage/nfs-client
folder. Edit the contents of the deploy/deployment-arm.yaml
file to adapt to your NFS server, change the PROVISIONER_NAME value
to e.g. nfs-storage, change the NFS_SERVER value
to your NFS server IP-address and the NFS_PATH value
to suite your NFS server.
NOTE: 5 lines in total should be modified.
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-client-provisioner
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: nfs-client-provisioner
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-client-provisioner
spec:
serviceAccountName: nfs-client-provisioner
containers:
- name: nfs-client-provisioner
image: quay.io/external_storage/nfs-client-provisioner-arm:latest
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: nfs-storage
- name: NFS_SERVER
value: 192.168.1.26
- name: NFS_PATH
value: /media/SEAGATE/kubernetes/nfs
volumes:
- name: nfs-client-root
nfs:
server: 192.168.1.26
path: /media/SEAGATE/kubernetes/nfs
Edit the contents of the deploy/class.yaml
file and change the provisioner:
to what you used for PROVISIONER_NAME value
above.
The deploy/rbac.yaml
file contains config needed for role based access control.
Time to apply the 3 yaml-files:
k apply -f deploy/rbac.yaml -f deploy/class.yaml -f deploy/deployment-arm.yaml
Login to the K3s dashboard to check that no errors are listed.
Then you can test that your NFS PVCs works:
k create -f deploy/test-claim.yaml -f deploy/test-pod.yaml
# Now check your NFS Server mount for the file SUCCESS.
k delete -f deploy/test-pod.yaml -f deploy/test-claim.yaml
# Now check the folder has been deleted.