Kubernetes is dropping support for Docker. Now, all the hard work you put into learning will change a lot. Even from the start, using Kubernetes will not be the same.
I'm talking about installing the container management tool itself. You, of course, cannot deploy Kubernetes in the same way as you once did - with Docker installed as your runtime.
Together we will now try to install Kubernetes on Ubuntu Server 20.04 without Docker.
What do you need
- User with sudo privileges
- Ubuntu Server 20.04 Instance (this will serve as the Controller - you will need other instances to run as nodes, but I'm only going to demonstrate on the Controller since the setup 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. Login to your Ubuntu Server instance and be sure to update apt using the command:
sudo apt-get update
After that, you must start the update with the command:
sudo apt-get upgrade -y
If the kernel is being updated, you need to reboot the server (unless you have Live Patch installed and running).
Install containerd using the command:
sudo apt-get install containerd -y
Configure containerd and start the service using 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 GPG key using the command:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
Add the Kubernetes repository using the command:
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
Now you can install all the required Kubernetes components using the command:
sudo apt-get install kubeadm kubelet kubectl –y
How to solve multiple containerd problems
This is where things get a little tricky. Docker has solved a lot of internal things. When you go to containerd you need 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 this file open, add the following below:
net.bridge.bridge-nf-call-iptables = 1
Save and close the file.
Then enter the commands:
sudo -s sudo echo '1' > /proc/sys/net/ipv4/ip_forward exit
Reload the configurations with the command:
sudo sysctl --system
You will also need to load a couple of required modules using the commands:
sudo modprobe overlay sudo modprobe br_netfilter
Once you take care of this, you can initialize Kubernetes.
How to complete the setup
You will need to list all your hosts in / etc / hosts. Make sure the display is of the form:
IP Address hostname
The next step is to set the hostname of your controller (make sure it matches the hostname you used in / etc / hosts) using the command:
sudo hostnamectl set-hostname HOSTNAME
Where HOSTNAME is the hostname you want to use.
Disable swapping by opening the fstab file for editing with the command:
sudo nano /etc/fstab
In this file, comment out (by adding a # at the beginning of the line) the entry that starts with:
/swap.img
This line will now start with:
# / swap.img
Save and close the file.
Disable swap with the command:
sudo swapoff -a
Extract the necessary containers with the command:
sudo kubeadm config images pull
On the controller, initialize Kubernetes using 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 that you need to run on your nodes so that they can connect to the cluster. Copy this command.
Before you can join the nodes to the cluster, you need to take care of a few more bits in the cluster.
On the controller, create the cluster directory using the command:
mkdir -p $ HOME / .kube
Copy the config file to this directory using the command:
sudo cp -i /etc/kubernetes/admin.conf $ HOME / .kube / config
Give the config file the appropriate permissions with the command:
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Deploy the container network (in this case we will use weave-net) in the cluster using the command:
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
You can now run a connect command on each of the nodes to shut down the cluster.
The process is not as simple as it used to be. Hopefully in the future, deploying a Kubernetes cluster will be as easy as using Docker.