Skip to Content

Install Kubernetes on Ubuntu 20.04 with CRI-O

This tutorial will show you how to install Kubernetes on Ubuntu Linux 20.04 using CRI-O as the container runtime and Calico for the Pod network add-on.

Overview of steps

First we will prepare the Ubuntu server for Kubernetes by disabling Swap, configuring the network and installing CRI-O. Then we will install kubeadm and Kubernetes. Finally, we will use kubeadm to create a single node cluster and deploy the Calico Pod network add-on.

Software versions:

  • Kubernetes v1.23.4
  • CRI-0 v1.23.1
  • Calico

Step 1: Disable Swap

As of writing, Kubernetes requires that Swap is disabled on the Linux server so that the kubelet process can reliably schedule memory to the pods. To disable swap, run the following command:

sudo swapoff -a

To make the change permanent, you will need to edit the fstab file.

Open /etc/fstab, remove the line containing swap and then save the file.

/swap.img       none    swap    sw      0       0

This will prevent swap from being enabled the next time the system boots.

Step 2: Configure the Network

  1. Assign a static IP address (I’ve used in this guide) – Tutorial
  2. Assign a hostname (I’ve used k8s-master in this guide) – Tutorial
  3. Configure iptables to see bridged traffic.
# Create the .conf file to load the modules at bootup
cat <

Step 3: Install CRI-O

Add the Kubic repository because it contains the binary packages of CRI-O.


# Add Kubic Repo
echo "deb$OS/ /" | \
sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list

# Import Public Key
curl -L$OS/Release.key | \
sudo apt-key add -

# Add CRI Repo
echo "deb$VERSION/$OS/ /" | \
sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list

# Import Public Key
curl -L$VERSION/$OS/Release.key | \
sudo apt-key add -

Update the package list and then install CRI-O.

sudo apt update
sudo apt install cri-o cri-o-runc cri-tools -y

Enable the CRI-O service so that it starts when Ubuntu does.Advertisements

sudo systemctl enable crio.service

Start the CRI-O service now.

sudo systemctl start crio.service

You can check to see if the container runtime is ready by running.

sudo crictl info
  "status": {
    "conditions": [
        "type": "RuntimeReady",
        "status": true,
        "reason": "",
        "message": ""
        "type": "NetworkReady",
        "status": false,
        "reason": "NetworkPluginNotReady",
        "message": "Network plugin returns error: No CNI configuration file in /etc/cni/net.d/. Has your network provider started?"

Step 4: Install Kubernetes

Download the public signing key.

sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg

Add the Kubernetes apt repository:

echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

Update apt package index, install kubeletkubeadm and kubectl, and pin their version:

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Step 5: Create Cluster

sudo kubeadm init --pod-network-cidr=

Make kubectl work for current user.

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Remove the taints from this node so that it can be used as a worker node.

kubectl taint nodes --all

Step 6: Install Calico Pod network add-on

Run the following commands to deploy the Calico Pod network add-on:

kubectl apply -f

You can check to see if the pods have started with the following watch command:

watch kubectl get pods -n kube-system

Wait until each pod has the STATUS of Running then terminate the watch utility.

Check to see if the node is ready with the following command:

kubectl get nodes -o wide

You should see an output like the following:

k8s-master      Ready    control-plane,master   3m55s   v1.23.4             Ubuntu 20.04.4 LTS   5.4.0-100-generic   cri-o://1.23.1


Congrats! You now have a single node Kubernetes cluster running on Ubuntu 20.04. We used CRI-O as a lightweight alternative to the Docker container runtime and we used Calico for the Pod network. You’re now ready to deploy some pods or join some worker nodes to the cluster.