Bootstrap Kubernetes cluster with PV as NFS

Create three ec2 instance

Master node : centos
Worker node: centos
NFS server : ubuntu

Steps to create NFS Server on ubuntu instance

Make sure you have below inbound rules for NFS client to ping to NFS server and mount directory on client-server

Setup Master node (control plane) - Install Docker and Kubernetes (kubeadm, kubectl, kubelet)

Add below Inbound rules with masternode of kubernetes cluster

Setup Worker Node

Install Docker, kubeadm, kubelet and kubectl as done in above steps for master node

1) Login to worker node

2) Add below inbound rules on worker nodes (Without adding port TCP/UDP 2049/111 you won’t be able to mount worker node on NFSdirectory)

3) Run token which you got from kubeadm init command: $ kubeadm join 1X2.3X.4.XXX:6443 --token XXXXXXXXXXXXXXXXXXXXXXX\ --discovery-token-ca-cert-hash sha256:XXXXXXXXXXXXX

4) $ sudo yum install nfs-util

5) mount -t nfs :/srv/nfs/mydata /mnt 6) mount | grep mydata

Create PV, PVC and POD’s to Use NFS server as underlying storage:

1) Login back to master node

2) Run $kubectl get nodes (this should list one master and worker node as Ready)

Create default nfs-storageclass.yaml

Create nfs-pv.yaml file with below contents

Create pvc.yaml

Create nfs-deployment.yaml

Any file created on location /usr/share/nginx/html will be backed up on NFS server location /srv/nfs/mydata

NOTE ** Contents of yaml can be found at TechSlaves Repo: deployment-pv-nfs **

Written on January 14, 2021