Follow Create a single-master Kubernetes cluster with kubeadm by Ansible to set up a Kubernetes cluster.
cd nfs-subdir-external-provisioner
vagrant up
Source: https://www.tecmint.com/install-nfs-server-on-ubuntu/
ssh [email protected]
sudo apt update
sudo apt install nfs-kernel-server
sudo mkdir -p /mnt/nfs_share
sudo chown -R nobody:nogroup /mnt/nfs_share/
sudo chmod 777 /mnt/nfs_share/
If you run sudo ls /mnt/nfs_share/
, it should return empty directory.
sudo vi /etc/exports
Add following lines to grant access from workers
/mnt/nfs_share 172.16.0.0/16(rw,insecure,sync,no_subtree_check)
sudo exportfs -a
sudo systemctl restart nfs-kernel-server
Check firewall status
sudo ufw status
If your firewall is enabled, then allow workers to connect to NFS port.
sudo ufw allow from 172.16.0.0/16 to any port nfs
sudo ufw status numbered
Worker 1
ssh [email protected]
sudo apt update
sudo apt install nfs-common
Worker 2
ssh [email protected]
sudo apt update
sudo apt install nfs-common
Worker 3
ssh [email protected]
sudo apt update
sudo apt install nfs-common
Source: https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner
Install
helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
--set nfs.server=172.16.4.11 \
--set nfs.path=/mnt/nfs_share
If you want to uninstall nfs-subdir-external-provisioner
, run helm uninstall nfs-subdir-external-provisioner
.
List StorageClass
kubectl get storageclass
There is nfs-client
StorageClass created.
kubectl apply -f my-nginx-pvc.yaml
kubectl get pvc
my-nginx-pvc
PersistentVolumeClaim is in Bound
status. You should note the VOLUME
hash.
kubectl apply -f my-nginx-deploy.yaml
kubectl get pod
SSH to NFS Server, and check shared directory.
ssh [email protected]
cd /mnt/nfs_share
ls -alh
There is a directory inside /mnt/nfs_share
, it has the VOLUME
hash that you see above.
cd _VOLUME_HASH_DIRECTORY_
echo "Hello from a PV on NFS Server" >> index.html
Create service
kubectl apply -f my-nginx-svc.yaml
kubectl get svc
Open http://172.16.1.11:30080/
on browser.