Single Control Plane Cluster Setup using Kubeadm

3 October 2019

Single master cluster setup using Kubeadm

Kubeadm is a tool built to provide best-practice “fast paths” for creating Kubernetes clusters. It uses kubeadm init and kubeadm join type simple commands for creating a better end-user experience for cluster creation & maintenance.
It enables Kubernetes administrators to quickly and easily bootstrap minimum viable clusters that are fully compliant with Certified Kubernetes guidelines.

As a defacto cluster creation tool, it has been used by projects like minikube, kops, etc.

Kubeadm is focused on bootstrapping Kubernetes clusters on existing infrastructure and performing an essential set of maintenance tasks. Its scope of work includes :

  • Creating a control plane node (master node) by kubeadm init & joining other master and worker nodes by kubedm join command.
  • It also includes various utilities for performing management tasks like control plane upgrades on already bootstrapped clusters, token and certificate renewal.

What kubeadm is not supposed to do

  • Infrastructure provisioning and direct infrastructure manipulation(as done by kops for cloud/on-prem or minikube for local)
  • Third-party networking integration
  • Monitoring /logging etc.
  • Specific cloud provider integration (This actually is handled well by Cloud Controller Manager which will be discussed in details in another blog post)

Creating a Single Control plane cluster using kubeadm

Now let's get our hands dirty with the installation & configuration of kubeadm to deploy a cluster with a single master and 2 worker nodes.

Prerequisites

  • 3 Virtual machines with Ubuntu 18.04 installed and sudo privileges. Name one node as master & other 2 as worker1 & worker2 repectively.
  • 2 GB or more of RAM per machine.
  • 2 CPUs or more on all nodes.

End Goal

  • Setup a Kubernetes cluster with a single master node & two worker nodes
  • Complete networking setup for the cluster so that Pods can talk to each other

Video

Steps to be followed on all nodes

  • Install container runtime on all three nodes (Docker in the current tutorial)

Ref: https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker

Copy Code
Loading...

Installing kubeadm, kubelet and kubectl

We will install the following packages on all three nodes:

  • kubeadm: the tool to bootstrap the cluster.
  • kubelet: the component that runs on all of the machines in your cluster as systemd process and does things like starting pods and containers.
  • kubectl: the command line utility to talk to your cluster.
Copy Code
Loading...

Setup Control Plane on the node with hostname set to master

Copy Code
Loading...

After running kubeadm init successfully we get output that the master node is initialized & we get some command to setup kubectl & also a command for joining worker nodes to this master node.

Note: We are using Calico as a network plugin, so we are using "--pod-network-cidr=192.168.0.0/16" option

  • Setup kubectl
Copy Code
Loading...

Setup Kubernetes network by installing Calico network plugin

Copy Code
Loading...

Finally, look for master Node status

Copy Code
Loading...
Copy Code
Loading...

Setup worker nodes

  • Copy the kudeadm join command from the output of kubeadm init and run on the worker nodes to join them to the cluster.
  • To regenerate kubeadm join command output to join worker nodes run below command on master node & use the output to join the worker nodes.
Copy Code
Loading...

Final status check of cluster

  • Run kubeadm get nodes on master node again to check the status of worker nodes
Copy Code
Loading...

Find cluster information

Copy Code
Loading...
Copy Code
Loading...

As seen above in kubectl cluster-info output our single control plane setup is complete & cluster is up and running with control plane master running on Node master with ip https://157.245.118.253:6443 & KubeDNS is running at endpoint as mentioned above. Next, we can check the health of control plane components.

  • Check the health status of various components of the control plane.
Copy Code
Loading...
Copy Code
Loading...

All the control plane components are up & in a healthy state.

Conclusion

As seen above kubeadm has made single control plane setup a real easy & no-sweat job.
In the next article of the kubeadm series we will discuss steps for setting up a HA Multimaster control plane.