Configure Kubernetes cluster on Ubuntu 18.04.1

Depending on availability, you may download and install Ubuntu on either VMware workstation/fusion or get a playground servers on online lab platforms.

System requirements:

Kubernetes Master Node:
VCPU = 2
Memory 2 GB
label= k8-Master
Network Adapter: Bridge Networking
Static IP: <ip>/24


Install below pre-requisites on all 3 servers for k8 to function as expected

sudo swapoff /swapfile

verify docker version on all 3 nodes

# sudo docker version

Step 2: Install kubeadm, kubelet and kubectl on all 3 nodes

curl -s | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

At this moment, kubectl and kubelet command wouldn’t work since we didn’t form k8 cluster

Step3: Bootstrap cluster -

On k8 master node, initialize the cluster and observer if there are any errors.

kubeadm init --pod-network-cidr=
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
ls -lah $HOME/.kube/config
-rw------- 1 root root 5.4K Nov 2 12:26 /root/.kube/config

Verify and ensure kubectl is responsive on master node

Step 4: Join worker nodes to Master

During kubeadm init operation, you would have got the token and cert details. Join the worker nodes to master with cert and token

kubeadm join <masterip>:6443 --token <token> --discovery-token-ca-cert-hash <cert>

Now from master, verify that all nodes have successfully joined cluster. The nodes are expected to have status ‘NotReady’ at this point

Step 5: Configure Networking

We have setup kube cluster but haven’t configured cluster networking for cluster to be fully operational

On all nodes, update iptables

echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf

Calico is one of the widely used component for networking in k8. Install it on cluster with below cmds (only on master)

curl -O

Check node status with ‘kubectl get nodes’. Create a new pod and ensure status returned as ‘running’

kubectl get nodes
kubectl run nginx --image=nginx
$ kubectl get pods
nginx 1/1 Running 0 11s



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store