Skip to main content
In this guide, you’ll learn how to install kubeadm along with the kubelet package on both the control plane and worker node (node1). To follow along, open two terminal sessions: one for the control plane and one via SSH connected to node1.

Step 1: Configure Container Runtime Forwarding Rules

Before installing the Kubernetes components, configure the necessary system forwarding rules on both nodes. Run the following command on both the control plane and node1:
The output might also recommend installing a specific version of the Kubernetes packages. Keep this in mind as you progress through the installation.

Step 2: Install kubeadm, kubelet, and kubectl

Follow the steps below to install the Kubernetes components on both the control plane and node1. These instructions are based on Ubuntu; adjust as necessary for your distribution.

1. Update the Package Repository and Install Prerequisites

2. Add the Google Cloud Public Signing Key

If your Ubuntu release (e.g., Ubuntu 22.04) does not have the /etc/apt/keyrings directory, create it first:

3. Set Up the Kubernetes apt Repository

4. Update the Package List and Install Components

If you need to install version 1.26.0 specifically, run:

Step 3: Verify Your Distribution

Before continuing, confirm that you’re using the correct distribution. Run:
A sample output might be:

Step 4: Addressing GPG Key and Repository Setup Errors

Sometimes an error may occur similar to:
If you encounter the error above, first create the required directory:sudo mkdir -p /etc/apt/keyringsThen re-run the curl command to download the key. Once the key is successfully downloaded, proceed with updating the package lists and installation:
A sample session might look like:

Step 5: Verify the kubelet Version

After installation, confirm the kubelet version with:
You should see output similar to:

Step 6: Bootstrap the Kubernetes Cluster

Since the cluster is not yet initialized, attempting to list nodes will generate errors. On the control plane, run:
Expected errors might include:
This is normal because the cluster still requires initialization with kubeadm.

Identify the Control Plane IP Address

Before initializing, check the IP address of your control plane’s primary interface (for example, eth0):
A sample interface output might be:

Initialize the Cluster

Using the control plane’s IP (e.g., 192.7.220.6), initialize the cluster with a specified pod network CIDR:
Upon successful initialization, the output will provide instructions to set up your default kubeconfig file. Follow these steps on the control plane:
Verify the status of the nodes:
At this point, you should see your control plane node listed—although it may be in a NotReady state until all components initialize.

Step 7: Generate and Use the kubeadm Join Token

After initialization, a join token is provided in the kubeadm output. You can choose to generate a new token or use the one provided.

On Node1, Configure the kubeconfig

Join the Cluster on Node1

Replace the IP address, token, and hash with those provided in your kubeadm init output:

Verify the Cluster Nodes

On the control plane, check if node1 has joined the cluster:
A sample output could be:
To validate on node1, you might also run:

Step 8: Install a Network Plugin

For pods to communicate across nodes, you must install a network plugin. The kubeadm output provides a list of available network add-ons. In this lesson, we will install Flannel. On the control plane, run:
Wait a few seconds for the components to initialize. Verify that all pods are running with:
You should now see the Flannel pods alongside the control plane and node details.

Summary

With these steps completed, you have successfully accomplished the following:
  1. Configured the system forwarding rules.
  2. Installed the necessary Kubernetes components (v1.26.0).
  3. Bootstrapped the control plane.
  4. Joined a worker node (node1) to the cluster.
  5. Deployed the Flannel network plugin for pod networking.
This concludes the Kubernetes cluster setup lab. For further details and troubleshooting, refer to the official Kubernetes Documentation.

Watch Video