Bootstrapping a Kubernetes cluster using Kubeadm

Filed Under: Random
Bootstrapping A Kubernetes Cluster Using Kubeadm

Hello, readers. This article talks about Bootstrapping a Kubernetes cluster using kubeadm with a detailed explanation.

So, let us begin!! 馃檪

Also read: Upgrading a Kubernetes Cluster using kubeadm tool


Bootstrapping a Kubernetes Cluster – Overview

The kubeadm tool enables us to create and bootstrap a Kubernetes cluster easily by joining the nodes together. It is a good tool to use in case of the below scenarios-

  1. For the ones who are using Kubernetes for the first time.
  2. If we want to set up an automated cluster and test its application.
  3. To install other tools with a larger scope.

We can also integrate the kubeadm tool with Ansible or Terraform for a seamless automated installation.


Pre-requisites for a Kubernetes Cluster creation

  1. One or more server/virtual machines running on a linux based operating system.
  2. A minimum of atleast 2Gi of RAM for every machine.
  3. Every control plane node should have atleast 2CPUs
  4. Full fledged network connectivity amongst all the nodes/machines within the cluster.

1. Installation of kubeadm package on all the nodes

In order to bootstrap a cluster, it is essential for us to install the kubeadm tool on all the nodes that are meant to be a part of the cluster.

For the same, we would need to have a container runtime plugin in the node as well as kubelet and kubectl on every node because kubeadm does not install or manage the kubelet and kubectl packages on any of the nodes.

Once done, we can then proceed with the creation of the cluster and bootstrapping of the same.


2. Initialization of control-plane node i.e. master node

A control plane node or a master node is a machine on which all the control plane components such as etcd, API server, etc sit and run effectively.

We need to initialize the control plane node for the following-

  1. Need to specify the –control-plane-endpoint in order to set the endpoint to the shared nodes by all the control plane nodes or master nodes.
  2. We would be needing a pod network plugin. This plugin will enable the pods to have an IP address once the pods are ready to be scheduled.
  3. A container runtime engine would be needed to run and monitor the containers within the kubernetes cluster once spinned up.
  4. The kubeadm tool usually uses the network interface details that is associated with the default gateway of the node to set the address for the master node’s API server. To do so, we can specify the –apiserver-advertise-address=<ip-address> for it.

Command to initialize a control plane node-

kubeadm init <args>

3. Installation of a Pod network plugin

At first, after execution of the above step, we need to run the below commands as a normal user-

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Post which we need to install a network plugin now-

kubectl apply -f [podnetwork].yaml

There is various network plugin available such as weave net, kubenet, flannel, etc. Any of the network plugins will suit the requirement.

This network plugin helps our pods have an IP address from the specified subnet.


4. Joining worker nodes to the control plane node

After having initialized the control plane and installed the network plugin, let us now join other nodes to the control plane using the below command-

kubeadm join <control-plane-host>:<control-plane-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash>

By this, we can as many numbers of worker nodes to the master node so that the pods would then start getting scheduled on them.


5. Isolating the Control plane node

Usually, none of the pods gets scheduled on the control plane due to security constraints. On a default basis, if we wish the pods to get scheduled on any particular node, we need to make sure that the pod tolerates all the taints that are applied on the node.


Conclusion

By this, we have approached the end of this topic. Feel free to comment below in case you come across any questions.

For more such posts related to Docker and Kubernetes, Stay tuned with us.

Till then, Happy Learning!! 馃檪

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content