Skip to main content
In this guide, we’ll walk through bootstrapping a Kubernetes cluster using kubeadm. The setup involves three virtual machines (VMs): one control plane (master) node and two worker nodes. We will review the VM network configurations, install the container runtime and Kubernetes components, initialize the control plane, deploy a pod network add-on, and finally join the worker nodes to complete the cluster.

1. VM Overview and Network Interfaces

Before you start, ensure that all required VMs are created. The cluster consists of one master and two worker nodes. Verify the network interfaces on each node by executing the ip add command.

Master Node Network Configuration

Run the following command on the master node:

Worker Node One Network Configuration

On the first worker node, run:

Worker Node Two Network Configuration

On the second worker node, verify the network configuration:
The output confirms that each node has the correct network interfaces and associated IP addresses, ensuring both dynamic and static configurations are in place.
The image shows a webpage from Kubernetes documentation detailing the installation of kubeadm, kubelet, and kubectl, including container runtime requirements and Unix domain socket paths.

2. Reviewing Prerequisites

Before initializing your Kubernetes cluster, verify the following prerequisites:
  • A supported Linux distribution (e.g., Ubuntu).
  • A minimum of 2 GB memory and at least two CPUs per node.
  • Required kernel modules (BR, netfilter, overlay) are loaded.
Ensure that system variables are correctly set (to 1) so the network interfaces function properly. For more details, refer to the official Kubernetes Documentation.

3. Installing the Container Runtime (ContainerD)

A container runtime is essential on every node. In this example, we will use ContainerD.

Step 1: Add the Kubernetes Repository and GPG Key

Execute these commands on all nodes:

Step 2: Install ContainerD

Run these commands on each node to install ContainerD:
Now, install ContainerD:
Verify the installation:

Step 3: Configure ContainerD for the systemd Cgroup Driver

It is critical that both ContainerD and kubelet use the same cgroup driver. Since systemd is the init system (check via ps -p 1), update the ContainerD configuration:
For further details on cgroup drivers, please review the container runtime documentation.
The image shows a webpage from the Kubernetes documentation, detailing container runtimes and configuration instructions for kubeadm, including notes and cautions.
The image shows a Kubernetes documentation page about configuring container runtime and kubelet cgroup drivers, including instructions and code snippets for setting up the systemd driver.

4. Installing kubeadm, kubelet, and kubectl

After configuring the container runtime, install the Kubernetes components. Holding these packages prevents unintentional upgrades:
The components serve the following purposes:
  • kubeadm: Bootstraps and manages the cluster initialization.
  • kubelet: Manages pods and containers on every node.
  • kubectl: Provides the command-line interface to interact with the cluster.

5. Initializing the Kubernetes Cluster

On the master node, initialize the control plane with kubeadm init, making sure to specify the following:
  • --pod-network-cidr: Sets the CIDR for pod networking (e.g., “10.244.0.0/16”).
  • --apiserver-advertise-address: Uses the master node’s static IP.
Before proceeding, verify the master node’s IP address:
For instance, if your master node’s static IP is 192.168.56.11, run:
After initialization, an admin.conf file is created. Configure kubectl by copying this file:
Confirm access to the cluster by checking the pods:
A lack of pods in the default namespace indicates that the cluster is successfully initialized.

6. Deploying a Pod Network Add-on

To enable inter-pod communication, deploy a pod network add-on. In this demo, we use Weave Net. Run the following command on the master node:
Replace [podnetwork].yaml with the URL or local file path to the Weave Net configuration file. This command deploys a DaemonSet that ensures the network add-on is applied across the control plane and later propagates to worker nodes. Verify the network add-on by checking the pods:
Ensure the Weave Net pods are running on the control plane. Adjust network settings if necessary to match the pod network CIDR used during initialization.

7. Joining Worker Nodes to the Cluster

Once the pod network is deployed, add your worker nodes to the cluster using the kubeadm join command printed by the kubeadm init process. For example, run the following command on each worker node:
After joining, verify the nodes from the master node:
All nodes (master and workers) should appear with a “Ready” status.

8. Verifying the Cluster

To ensure that your Kubernetes cluster is operational, deploy a test pod (for example, an nginx container):
Once the test pod is in the Running state, your cluster setup is complete. You may remove the test pod when finished.

Conclusion

This guide covered the following steps to bootstrap your Kubernetes cluster using kubeadm:
  1. Reviewed VM network configurations.
  2. Installed and configured ContainerD as the container runtime.
  3. Installed Kubernetes components (kubeadm, kubelet, and kubectl).
  4. Initialized the control plane with kubeadm init (including specifying pod network CIDR and the API server advertise address).
  5. Deployed a pod network add-on (Weave Net).
  6. Joined the worker nodes to the cluster.
  7. Verified cluster functionality with a test pod deployment.
You have now successfully set up your Kubernetes cluster from scratch using kubeadm. Happy clustering!

Watch Video

Practice Lab