Hey Isha, Follow these steps to create a kube cluster with one master and one node on ubuntu.
Execute these steps on master as well as nodes:
$ sudo su
$ apt-get update
Turn off the swap space:
swapoff -a
Go to the following file and comment out the line which mentions swap.
nano /etc/fstab
Go to /etc/hostname of master node and change the name to kmaster
Go to /etc/hostname of the worker node and change it to knode
Go to /etc/hosts file of the master and add the IP address of your kmaster and knode
Do the same for all the worker nodes.
Make the IP addresses static. Go to
nano /etc/network/interfaces
and add these lines:
auto enp0s8
iface enp0s8 inet static
address <IP-Address-Of-VM>
Install Docker
$ sudo su
$ apt-get update
$ apt-get install -y docker.io
Install Kubernetes Environment
$ apt-get update && apt-get install -y apt-transport-https curl
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
$ cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
$ apt-get update
Install kubeadm, kubectl and kubelet
$ apt-get install -y kubelet kubeadm kubectl
Change the config file of kubernetes, go to the following file:
nano /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
Add this:
Environment=”cgroup-driver=systemd/cgroup-driver=cgroupfs”
Execute this only on Kubernetes master:
kubeadm init --apiserver-advertise-address=<ip-address-of-kmaster-vm> --pod-network-cidr=192.168.0.0/16
Run these commands as a non root user:
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
Go to the worker node and execute the join command mentioned in the master
Verify if all your pods are running from the master:
$ kubectl get pods -o wide --all-namespaces
And your cluster is ready :)