...
volumes:
- name: nfs
nfs:
server: <NFS_SERVER_IP>
path: /
Dynamic Volumes with the NFS Client Provisioner
For an easy way to get up and running serving shared volumes on Kubernetes from an existing NFS server, check out the nfs-client provisioner.
...
For more details, see https://kubernetes.io/docs/concepts/storage/persistent-volumes/#dynamic
...
In-Cluster Server Example
Following this example, I was able to easily get an NFS server pod running within a Kubernetes 1.9 cluster.
...
Code Block | ||
---|---|---|
| ||
# Create some duplicate pods consuming the same NFS mount ubuntu@mltf-master:~/kubernetes-nfs-server$ kubectl create -f web-pod2.yaml -f web-pod3.yaml pod "web2" created pod "web3" created # Wait for containers to start ubuntu@mltf-master:~/kubernetes-nfs-server$ kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE nfs-server-wc8h6 1/1 Running 0 49m 10.244.1.4 mltf-storage0 web 1/1 Running 0 39m 10.244.3.2 mltf-storage1 web2 0/1 ContainerCreating 0 8s <none> mltf-storage0 web3 0/1 ContainerCreating 0 8s <none> mltf-worker0 # Verify that the file created inside of our original web pod (running on "storage1") also shows up here ubuntu@mltf-master:~/kubernetes-nfs-server$ kubectl exec -it web2 -- cat /usr/share/nginx/html/pod-write asdf 1234 Hello, World! ubuntu@mltf-master:~/kubernetes-nfs-server$ kubectl exec -it web3 -- cat /usr/share/nginx/html/pod-write asdf 1234 Hello, World! |
Dynamic Volumes using the NFS Provisioner
See https://github.com/kubernetes-incubator/external-storage/tree/master/nfs
...
Congratulations! Wasn't that easy?
Testing it Out
A simple test case for consuming a dynamic PVC can be found below:
...