VOOZH about

URL: https://thenewstack.io/how-to-deploy-kubernetes-with-kubeadm-and-containerd/

⇱ How to Deploy Kubernetes with Kubeadm and containerd - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-03-26 09:00:26
How to Deploy Kubernetes with Kubeadm and containerd
tutorial,
Kubernetes

How to Deploy Kubernetes with Kubeadm and containerd

This post details a method of deploying a Kubernetes cluster is with kubeadm (a tool that helps fast-track your deployment) and containerd (a container runtime engine).
Mar 26th, 2022 9:00am by Jack Wallen
👁 Featued image for: How to Deploy Kubernetes with Kubeadm and containerd

There’s no easy way to say this, but Kubernetes is challenging. And although at one time it was actually fairly simple to deploy a Kubernetes cluster to bare metal (thanks, in part, to Docker), it’s not quite as simple as it once was. To complicate matters even further, there’s an almost endless amount of paths to getting the platform up and running.

Which one do you choose? The answer to that question depends on what you’re doing with Kubernetes, the platform you plan on deploying it to, and your operating system of choice.

One method of deploying a Kubernetes cluster is with kubeadm (a tool that helps fast-track your deployment) and containerd (a container runtime engine). That’s the method I want to illustrate here. Walk through this process and you’ll wind up with a working Kubernetes cluster. I’m going to limit it to just a master and one node (for simplicity), but you can deploy as many nodes as you need.

To do this, you’ll need at least two machines (one for the master and one for the node). I’m going to be demonstrating on my server of choice, Ubuntu 20.04). Each machine should have at least 2GB of RAM and the master should have at least two CPUs.

Set the Hostnames and Hosts Files

The first thing we’re going to do is set the hostnames for each machine. First, log into your master and issue the command:

sudo hostnamectl set-hostname kubemaster

Next, edit the hosts file with the command:

sudo nano /etc/hosts

In that file, add the following at the bottom:

kubemaster IP_ADDRESS
kubenode1 IP_ADDRESS

Where IP_ADDRESS is the IP address for each machine. Save and close the file.

Log into the node machine and set the hostname with:

sudo hostnamectl set-hostname kubenode1

Edit the /etc/hosts file in the same way you did on the master (using the same settings).

Install the Necessary Software

On both machines, you’ll need to install a few pieces of software. First, log into the master and Run an update/upgrade with the commands:

sudo apt update

sudo apt upgrade -y

If the kernel is upgraded, make sure to reboot the machine.

After the upgrade completes, install the first dependencies with:

sudo apt install curl apt-transport-https -y

Next, add the necessary GPG key with the command:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Add the Kubernetes repository with:

echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

Update apt:

sudo apt update

Install the required software with the command:

sudo apt -y install vim git curl wget kubelet kubeadm kubectl

Finally place kubelet, kubeadm, and kubectl on hold with:

sudo apt-mark hold kubelet kubeadm kubectl

Start and enable the kubelet service with:

sudo systemctl enable --now kubelet

Repeat this process on kubenode1.

Disable Swap

Next, we need to disable swap on both kubemaster and kubenode1. Open the fstab file for editing with:

sudo nano /etc/fstab

In that file, comment out the line:

/swap.img      none    swap    sw      0       0

That line should now look like:

#/swap.img      none    swap    sw      0       0

Save and close the file. You can either reboot to disable swap or simply issue the following command to finish up the job:

sudo swapoff -a

Enable Kernel Modules and Change Settings in sysctl

Next, we need to enable two kernel modules and add a few settings to sysctl. First, enable the overlay and br_netflilter modules with:

sudo modprobe overlay

sudo modprobe br_netfilter

Change the sysctl settings by opening the necessary file with the command:

sudo nano /etc/sysctl.d/kubernetes.conf

Look for the following lines and make sure they are set as you see below:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1

Save and close the file. Reload sysctl with:

sudo sysctl --system

Make sure to take care of the above on both kubemaster and kubenode1.

Install containerd

We’ll now install the containerd runtime engine. This is done on both machines. The first thing to do is configure the persistent loading of the necessary containerd modules. This is done with the following command (which you should copy and paste as-is):

sudo tee /etc/modules-load.d/containerd.conf <<EOF
overlay
br_netfilter
EOF

Once again, we reload the configuration with:

sudo sysctl --system

Install the necessary dependencies with:

sudo apt install curl gnupg2 software-properties-common apt-transport-https ca-certificates -y

Add the GPG key with:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the required repository with:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Install containerd with the commands:+-

sudo apt update

sudo apt install containerd.io -y

Change to the root user with:

sudo su -

Create a new directory for containerd with:

mkdir -p /etc/containerd

Generate the configuration file with:

containerd config default>/etc/containerd/config.toml

Exit from the root user with:

exit

Restart containerd with the command:

sudo systemctl restart containerd

Enable containerd to run at startup with:

sudo systemctl enable containerd

Finally, you need to create a new directory to house a configuration file and give it the proper permissions which is done with the following commands:

mkdir -p $HOME/.kube

sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

Initialize the Master Node

Go to kubemaster and pull down the necessary container images with:

sudo kubeadm config images pull

Now, using the kubemaster IP address initialize the master node with:

sudo kubeadm init --pod-network-cidr=IP/16

Where IP is the IP address of kubemaster. When the initialization command, you’ll be presented with something like:

sudo kubeadm join 192.168.1.100:6443 --token 0dt0kt.h4i71m34tbfqup83 --discovery-token-ca-cert-hash sha256:c74be4fd295c172ba0fd6bdae870a834b051327c45fa46cc9d738e74f5de82a0

The above command is what you then run on kubenode1 to join it to the cluster. The join should happen very quickly. Once it completes, go back to kubemaster and issue the command:

kubectl get nodes

You should see both your master and node listed. Congratulations, you’ve just deployed a Kubernetes cluster and can use it for development purposes.

I wouldn’t suggest using this for production because it’s too small to scale and we’ve not taken security into account (such as using SSL certs). But this is a great way to practice deploying the cluster and a viable introduction for Kubernetes development.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Docker, Enable.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.