Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to create a Kubernetes cluster using kubeadm

Mohan Pawar

The minimal viable Kubernetes (MVK) cluster

The kubeadm tool is used to bootstrap smaller Kubernetes clusters so that you can experience all the kubernetes features. The cluster spin-up using kubeadm is eligible to pass the Kubernetes Conformance Program. The cluster life-cycle functions and cluster upgrades are also supported by kubeadm.

If you are getting started with Kubernetes, then this is a perfect start to bootstrapping a cluster using kubeadm. If you want to test two or three node clusters, you can do it on your local machine or workstation by creating a guest operating system. You can automate these commands using any configuration management tool.

You can install kubeadm on your local machine or laptop, any of the cloud servers, or on Arduino, Raspberry Pi, etc.


  1. One or more machines running a Linux operating system like deb/rmp.
  2. 2 GiB+ of RAM/machine (works with less RAM, but you cannot run heavy resource applications later on).
  3. Minimum 2 vCPUs for the master node (control-plane node).
  4. Full network connectivity between machines (machines can either be in a public or private network).

Now that you have qualified the above prerequisites, you can quickly go to the installation process below. It has been divided into steps; for steps 1–9, you have to run on all the nodes on the cluster.

  1. Get the Docker GPG key,
curl -fsSL | sudo apt-key add -`
  1. Add the docker repository,
sudo add-apt-repository   "deb [arch=amd64]
     $(lsb_release -cs)\
  1. Get the Kubernetes GPG key,
 curl -s |  sudo apt-key add -
  1. Add the Kubernetes repository,
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main
  1. Update your packages,
sudo apt update -y
  1. Install Docker, kubelet, kubeadm, kubectl,
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.15.7-00 kubeadm=1.15.7-00 kubectl=1.15.7-00
  1. The versions of the components installed are compatible with each other; hence, I would recommend following​ the same,
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
apt-mark hold package command
apt-mark hold package command
  1. Add the IPtables rule to sysctl.conf, so that pods can communicate across nodes,
echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
  1. Enable IPtables immediately i.e., to get it effected,
sudo sysctl -p
  1. Initialize the cluster (run only on the master),
sudo kubeadm init --pod-network-cidr=
kubeadm init output
kubeadm init output

What happens when you run kubeadm init to create a Kubernetes native cluster?

It will first run a set of pre-flight checks that will validate the system state. You might get a specific error or warning at the command line. It will then generate a self-signed certificate, or use one of the existing certificates that have already been provided to set up the identities of different components of the master node. The same certificate will be used by the API-server as other components communicate with it. Next, it will setup the kubeconfig file into the /etc/kubernetes/ directory for kubelet, controller-manager, the scheduler, etc. Note that these components (like API-server, controller-manager, scheduler) are running inside the pod, and the static pod-manifest file for these pods in the control-plane has already been set-up on the master. So, the respective images will be pulled at this time. The init process will also apply labels and taints to the master node so that no additional workload will ever run there. Next, kubeadm will generate a token. This token can be specified by any nodes to join this cluster. Next, a couple of add-ons are set up on the master node as kube-dns and kube-proxy. Finally, you’ll see the steps to start using your cluster. You need to run the following steps as a regular user along with a join token, which we’ll need to run from the worker node to join the cluster.

  1. Set up local kubeconfig, make sure it is as mentioned in the above command’s output. Run the below commands as a regular user, not with root user (as seen in the above screenshot),
mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config
  1. Apply Flannel CNI network overlay,
kubectl apply -f
  1. Join the worker nodes to the cluster (run this on the worker nodes to join the cluster),
sudo kubeadm join [kubeadm_init_token]
  1. Verify that the worker nodes have joined the cluster successfully,
kubectl get nodes
get nodes command
get nodes command

Compare this result of the kubectl get nodes command. Now you have a ready cluster with you to test and deploy any application into the Kubernetes cluster. This is not a recommended way to run the Kubernetes applications into a ​production environment using kudeadm, but it’s very helpful to understand, learn, and experiment with the Kubernetes cluster.



View all Courses

Keep Exploring