Learn how to bootstrap Kubernetes clusters with kubeadm

Container orchestration is the process of deploying and managing containers throughout their lifecycle. Kubernetes is an open-source container orchestration platform that automates the management and deployment of containers and applies per-container policies.

Kubernetes automates the deployment, scaling, and management of containerized applications on a single host or across multiple hosts, making it a popular choice for organizations of all sizes. You can install and configure Kubernetes on bare metal or a VM.

What is bootstrapping a Kubernetes cluster?

Bootstrapping is the process of building a new Kubernetes cluster from scratch and getting it running.

Bootstrapping a Kubernetes cluster involves setting up the control plane and worker nodes, and determining which node has the right information to sync all other nodes to. You can do this manually, programmatically, or with kubeadm, a Kubernetes tool for setting up and managing clusters.

When should I boot a Kubernetes cluster?

Bootstrapping a cluster can be useful when starting from scratch or changing the configuration of an existing Kubernetes deployment. Bootstrapping is also useful when creating an isolated environment to test new features or work around known bugs, an approach known as release canary.

You may also want to create a new cluster from scratch if you are creating a custom Kubernetes installation and don’t need the standard software that comes with distributions like Debian or RHEL. For example, you may want to include newer versions of container runtimes than those included in RHEL version 7 or Debian version 9.

What is kubeadm and what does it do?

Kubeadm is a command-line tool that simplifies the setup and management of Kubernetes clusters. With kubeadm you can create and set up a Kubernetes infrastructure without any other orchestrators or tools. Kubeadm is suitable for both beginners starting out with Kubernetes and experienced users who want to quickly set up a new cluster.

Kubeadm automates the creation and configuration of the required components for a Kubernetes cluster, including setting up the control plane and worker nodes with the basic network and security configuration required to run Kubernetes on bare metal systems. Kubeadm sets up the underlying machinery needed for Kubernetes, downloads and installs the required software, configures networking, and sets up authorization. It also makes it easier to connect nodes to a cluster.

Requirements for bootstrapping a Kubernetes cluster with kubeadm

Running a Kubernetes cluster requires at least two nodes: a control plane and a worker node. Kubernetes only allows one control plane node, but any number of worker nodes. Control plane nodes require at least 2GB of RAM and a virtual CPU; Worker nodes require at least 2 GB of RAM and a vCPU.

In addition to kubeadm, you need the following packages to boot a Kubernetes cluster:

  • kubelet. This component registers nodes with a cluster and starts containers and pods. It runs on every node in the cluster and manages tasks like scheduling pods and launching containers.
  • cubectl. This command line utility manages clusters, nodes, and pods.

To install Kubernetes on Windows, install Docker for Windows, then select Enable Kubernetes in the Docker desktop UI. This will also install kubectl automatically.

Bootstrap a Kubernetes cluster with kubeadm

After installing Kubernetes, the next step is to configure it.

To set up kubeadm, create a configuration file called kubeadm.yaml. This file contains all the information kubeadm needs to set up your cluster. Kubeadm automates the process of creating a cluster by using the kubeadm init Command on a set of nodes that uses a YAML file to specify the desired settings for the new cluster.

Install kubectl on Windows or install kubectl from the command line with the following shell command:

curl -LO
https://dl.k8s.io/release/v1.24.0/bin/windows/amd64/kubectl.exe

To boot a Kubernetes cluster, ensure that the latest version of kubeadm is installed with the following command:

curl -sSL
https://github.com/kubernetes/kubeadm/releases/download/v1.0.1/kubeadm-1.0.1-linux-amd64 | bash

After installing kubeadm on your server, create a configuration file for the new cluster. The configuration file contains information about the desired settings for the new cluster.

Create the configuration file with the following command:

kubeadm init --config-file = config.yaml

The configuration file is located in the current working directory. Save it to a hard drive for future use by running the following command:

kubeadm init --save > config.yaml

Now start the cluster:

kubeadm up

Finally, run the following command to verify that the cluster is operational:

kubectl get nodes

Figure 1 shows the expected output.

The screenshot shows the cluster is up and running and shows all the cluster nodes.
Figure 1. The output shows the nodes of the cluster.

The following command lists all the pods that exist in the kube system namespace:

kubectl get po -n kube-system

Running this command should result in the output shown in Figure 2.

The screenshot shows all pods present in the kube-system namespace.
Figure 2. The output shows all pods present in the kube-system namespace.

Leave a Reply

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