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
![](https://www.edureka.co/community/?qa=blob&qa_blobid=4030613939937284609)
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.
![](https://www.edureka.co/community/?qa=blob&qa_blobid=13745040725481865344)
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>
![](https://www.edureka.co/community/?qa=blob&qa_blobid=14100676612477687400)
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”
![](https://www.edureka.co/community/?qa=blob&qa_blobid=10319257165305681302)
Execute this only on Kubernetes master:
kubeadm init --apiserver-advertise-address=<ip-address-of-kmaster-vm> --pod-network-cidr=192.168.0.0/16
![](https://www.edureka.co/community/?qa=blob&qa_blobid=10500778561222164018)
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
![](https://www.edureka.co/community/?qa=blob&qa_blobid=1141527726556267463)
And your cluster is ready :)