Setup master and worker node VM's
Setup VPS and install docker (all nodes)
Refer: https://projects-srv2.kondgekar.com/projects/cbofferwall/wiki/0000-preliminary-setup
Fix swap (all nodes)
Installing kubernetes needs swap should be disabled. Check if swap is enabled and then disable if swap is enabled.
Disable swap
sudo swapoff -a
Remove / comment out respective swap entry from fstab file
sudo nano /etc/fstab
Install kubeadm, Kubelet And Kubectl (all nodes)
Refer: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
Update Kubernetes Configuration (all nodes)
sudo nano /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
This will open a text editor, enter the following line after the last “Environment Variable”:
Environment=”cgroup-driver=systemd/cgroup-driver=cgroupfs”
Start kubernetes cluster (on master)
We are going to use Flannel as a networking for pods
sudo kubeadm init --apiserver-advertise-address=<ip-address-of-kmaster-vm> --pod-network-cidr=10.244.0.0/16
- You will get the below output. The commands marked as (1), execute them as a non-root user. This will enable you to use kubectl from the CLI
- The command marked as (2) should also be saved for future. This will be used to join nodes to your cluster
Execute commands as mentioned above.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Verify if cluster is running (on master)
kubectl get pods -o wide --all-namespaces
Notice that all pods are running except coredns. It will be running once we setup pod network in the next step
Install POD network (Flannel) (on master)
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl get pods -o wide --all-namespaces
Notice that all pods are now running
Install Kubernetes Dashboard (on master)
Refer: https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
Check available nodes (on master)
kubectl get nodes
Notice that only one node is available which is a master node.
Add worker node (on worker node)
Use below command to join Kuberneter cluster from worker node
kubeadm join <master-node-ip-address>:6443 --token <generated-token> \
--discovery-token-ca-cert-hash <generated-hash>
Check if node is added in cluster (on master)
Initially worker node will show status as not ready
Wait for some time and it will be shown as Ready
Kubernetes cluster is now running. You can now run containerized applications and make it available over web using specific setup
No Comments