Hello, readers. This article talks about Bootstrapping a Kubernetes cluster using kubeadm with a detailed explanation.
So, let us begin!! 🙂
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-
- For the ones who are using Kubernetes for the first time.
- If we want to set up an automated cluster and test its application.
- 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
- One or more server/virtual machines running on a linux based operating system.
- A minimum of atleast 2Gi of RAM for every machine.
- Every control plane node should have atleast 2CPUs
- 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-
- 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.
- 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.
- A container runtime engine would be needed to run and monitor the containers within the kubernetes cluster once spinned up.
- 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.
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!! 🙂