Kubernetes is deprecating Docker support. That’s right, all that hard work you’ve put into learning the container orchestrator is about to change. Even from the very beginning of the journey, how you use Kubernetes will not be the same.
I’m talking about the very installation of the container management tool. You certainly cannot deploy Kubernetes in the same fashion as you once did–installing Docker as your runtime. With that in mind, what do you do? I’m going to show you.
Together, we’re going to install Kubernetes on Ubuntu Server 20.04, without Docker.
What you’ll need
- A user with sudo privileges
- An instance of Ubuntu Server 20.04 (this will serve as the Controller–you’ll need other instances to serve as the nodes, but I’m only going to demonstrate on the Controller, as the installation will be the same on all machines)
How to install the containerd runtime
The first thing we’ll do is install the containerd runtime which will take the place of Docker. Log in to your Ubuntu Server instance and make sure to update apt with the command:
sudo apt-get update
Once that completes, you should run an upgrade with the command:
sudo apt-get upgrade -y
If the kernel upgrades, you’ll want to reboot the server (unless you have Live Patch installed and running).
Install containerd with the command:
sudo apt-get install containerd -y
Configure containerd and start the service with the commands:
sudo mkdir -p /etc/containerd
sudo su -
containerd config default /etc/containerd/config.toml
How to install Kubernetes
Next, we’ll install Kubernetes. First you need to add the repository’s 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 the command:
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
Now you can install all of the necessary Kubernetes components with the command:
sudo apt-get install kubeadm kubelet kubectl -y
How to solve a few problems introduced with containerd
This is where things get a bit tricky. Although the Kubernetes developers will tell you things should go smoothly, they don’t–at least not yet. With Docker, a lot of the under-the-hood stuff was taken care of. When you migrate to containerd, you have to make some manual configuration changes.
The first change is to add a line to /etc/sysctl.conf. Open the file with the command:
sudo nano /etc/sysctl.conf
With that file open, add the following at the bottom:
net.bridge.bridge-nf-call-iptables = 1
Save and close the file.
Next, issue the commands:
sudo echo '1' > /proc/sys/net/ipv4/ip_forward
Reload the configurations with the command:
sudo sysctl --system
You’ll also need to load a couple of necessary modules with the commands:
sudo modprobe overlay
sudo modprobe br_netfilter
Once you’ve taken care of the above, you should be able to finally initialize Kubernetes.
How to finish up the setup
You’ll need to map all of your nodes in /etc/hosts. Make sure that mapping is in the form of:
IP Address hostname
The next step is to set the hostname of your controller (making sure it matches the hostname you used in /etc/hosts) with the command:
sudo hostnamectl set-hostname HOSTNAME
Where HOSTNAME is the hostname you want to use.
Disable swap by opening the fstab file for editing with the command:
sudo nano /etc/fstab
In that file, comment out (by adding a # character at the beginning of the line) the entry that starts with:
That line will now start with:
Save and close the file.
Disable swap with the command:
sudo swapoff -a
Pull the necessary containers with the command:
sudo kubeadm config images pull
On the controller, initialize Kubernetes with the command:
sudo kubeadm init --pod-network-cidr=IPADDRESS/24
Where IPADDRESS is the IP Address of your controller.
You will eventually be returned to the command to be run on your nodes so that they can connect to the cluster. Copy that command.
Before you can join the nodes to the cluster, you have to take care of a few more bits on the cluster.
On the controller, create a cluster directory with the command:
mkdir -p $HOME/.kube
Copy the config file into this directory with the command:
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
Give the config file the proper permissions with the command:
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Deploy a pod network (in this case we’ll use weave-net) to the cluster with the command:
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '
Now you can run the join command on each of the nodes to finish up your cluster.
The process is not nearly as simple as it once was. Hopefully, in the future, Kubernetes cluster deployments will be as easy as they were when Docker was involved. Until then, if you opt to host the container orchestrator on your own hardware, these are the kinds of steps you’ll have to take.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.