Kubernetes easy install with Kubeadm
Auteur: Fabrice JAMMES (LinkedIn). Date: Jan 27, 2020 · 10 min read
This article explains how to install Kubernetes with kubeadm, the official Kubernetes installer. It is inspired by the official documentation, while declining it for Ubuntu and simplifying it.
It has been successfully tested with Kubernetes 1.31.0
Pre-requisites: Infrastructure
- One or more machines running Ubuntu LTS, with administrator access ( sudo)
- 2 GB or more of RAM per machine
- 2 or more processors on the master node
- Full network connectivity between all machines in the cluster
The ‘size-of-master-and-master-components’ documentation define some guidelines on how to size your masters nodes depending on the total number of your Kubernetes nodes.
Info
Attending the training? Two Ubuntu machines are already provisioned for
you: student<ID>-1 is the master, student<ID>-2 the worker, where <ID> is
the number of your training account. Reach them from the training server with
ssh student<ID>-1 — see Access to Labs.
Everything below is then run on those two machines.
Pre-requisites: System
Install containerd
containerd is a lightweight runtime for Linux containers. It is a reliable project, validated by the Cloud-Native Computing Foundation, as you can see on the CNCF landscape web page. The installation of containerd is required on all of your machines. Indeed, this is the basic brick that will allow Kubernetes to run and manage the containers. Copy and paste the code below in a script and execute it on each machine.
For more information regarding the installation of containerd, please check the official documentation.
Install kubeadm and its friends: kubelet and kubectl
kubeadmis the official Kubernetes installer, it must be run asrooton each nodes of your Kubernetes cluster.kubeletis the daemon in charge of running and managing the containers on every nodes controlled by Kubernetes. It must be available on all the nodes of the cluster, including the master nodes because it also manages the containers in charge of the Kubernetes system components. It uses the CRI specification (Container Runtime Interface) to communicate with the local container execution engine, in our examplecontainerd.kubectlis the Kubernetes client, install it on the machine that will allow you to control your Kubernetes cluster. As seen above, we recommend that you copy and paste the code below into a script and execute it on each machine.
Please note that the script prevents updates to kubeadm, kubectl, and kubelet which could be caused by the installation of security updates with apt-get commands.
Create the Kubernetes cluster
On your master node, run the following command:
Here is what will appear on your console, in the last lines of standard output:
There are three very important instructions here:
- how to configure
kubectl, the Kubernetes client. In our example we will use the Kubernetes master node as a client, on which we will therefore issue the commands below:
- installing a network plugin, here we choose a popular one:
cilium. Just run the command below on your Kubernetes client, which we just configured. Note that in our example it is also the master Kubernetes:
- the command to execute on all your other nodes so that they join the Kubernetes cluster:
<control-plane-host>:<control-plane-port> contains the DNS name or IP and port of the Kubernetes master. <token> is the token, whose lifetime is limited, which allows the current node to identify itself to the master. Finally, <hash> allows the current node to ensure the authenticity of the master.
Note
It is not recommended to run user workload on Kubernetes master node(s) for security reason. That’s why we recommend to use dedicated master node(s) for running Kubernetes system components.
Check that everything works
The following command checks that your Kubernetes cluster is up and running:
The command below list all nodes:
Finally, installing Kubernetes with kubeadm is rather simple, isn’t it :-).
Remove the cluster
The official documentation describes all the operations required to delete your cluster. If you have created your machines in a Cloud, an equivalent and much simpler solution is of course to delete all of them, and then recreate them in their initial state.
Automate installation
Here is a sample script to automate this process: https://github.com/k8s-school/k8s-advanced/tree/master/labs/0_kubeadm . To learn more, you can contact us and register to one of our training courses.