How to Install CRI-O Container Runtime on Ubuntu 20.04

CRI-O is an OCI-based implementation of Kubernetes Container Runtime Interface (CRI) Developed to provide an integration path between OCI-compliant runtimes and the Kubelet. It is a lightweight container runtime environment. A container runtime is the software that is responsible for running the containers. When installing kubernetes, you need to install a container runtime into each node in the cluster so that Pods can run there.

CRI-O was developed to provide the following core functions:

  • Supports multiple image formats including the existing Docker image format
  • Support for multiple ways to download images including trust and image verification
  • Container image management (management of image layers, overlay file systems, etc.)
  • Life cycle management of container processes
  • Monitoring and logging required to satisfy the CRI
  • Resource isolation according to CRI

In this guide we will install CRI-O in Ubuntu 20.04.

Related Content:

Step 1. Ensure that the server is up to date

It is always a good practice to ensure the system packages are updated. Use this command to ensure our Ubuntu system has up to date packages:

sudo apt update
sudo apt -y upgrade

Step 2. Set up Kubic repository repository for CRI-O

Add the Kubic repository that hosts binary packages for Debian based systems. If you are using CRI-O with Kubernetes, install the version that corresponds to the Kubernetes version you are setting up.

To install on the following operating systems, set the environment variable OS to the appropriate field in the following table:

Operating system$OS
Ubuntu 20.04xUbuntu_20.04
Ubuntu 19.10xUbuntu_19.10
Ubuntu 19.04xUbuntu_19.04
Ubuntu 18.04xUbuntu_18.04

Then, set $VERSION to the CRI-O version that matches your Kubernetes version. For instance, if you want to install CRI-O 1.22, set VERSION=1.22. You can pin your installation to a specific release. To install version 1.22.0, set VERSION=1.2:1.22.0.

Ensure you run these as root

OS=xUbuntu_20.04
VERSION=1.22

echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list

curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | apt-key add -
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | apt-key add -

Step 3: Install CRI-O

We can now install CRI-O after ensuring that our repositories are up to date.

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

To confirm the installed version, use this command:

$ apt-cache policy cri-o
cri-o:
  Installed: 1.22.1~1
  Candidate: 1.22.1~1
  Version table:
 *** 1.22.1~1 500
        500 http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/1.22/xUbuntu_20.04  Packages
        100 /var/lib/dpkg/status

Step 4. Start and enable CRI-O

Let us reload systemd units and start the service while enabling it on boot.

sudo systemctl daemon-reload
sudo systemctl enable crio --now

Confirm the app status:

$ sudo systemctl status crio
● crio.service - Container Runtime Interface for OCI (CRI-O)
     Loaded: loaded (/lib/systemd/system/crio.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-02-01 11:55:27 UTC; 45s ago
       Docs: https://github.com/cri-o/cri-o
   Main PID: 18644 (crio)
      Tasks: 11
     Memory: 9.8M
     CGroup: /system.slice/crio.service
             └─18644 /usr/bin/crio

Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.738388792Z" level=info msg="Installing default AppArmor profile: crio-default"
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.767489286Z" level=info msg="No blockio config file specified, blockio not configured"
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.767528847Z" level=info msg="RDT not available in the host system"
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.770004929Z" level=warning msg="Error validating CNI config file /etc/cni/net.d/100-crio-bridge.conf: [failed to >
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.770125954Z" level=warning msg="Error validating CNI config file /etc/cni/net.d/200-loopback.conf: [failed to fin>
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.770142128Z" level=info msg="Updated default CNI network name to "
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.869818511Z" level=warning msg="The binary conntrack is not installed, this can cause failures in network connect>
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.881122431Z" level=warning msg="The binary conntrack is not installed, this can cause failures in network connect>
Feb 01 11:55:27 ubuntusrv.citizix.com crio[18644]: time="2022-02-01 11:55:27.881351017Z" level=warning msg="Error encountered when checking whether cri-o should wipe images: version file /v>
Feb 01 11:55:27 ubuntusrv.citizix.com systemd[1]: Started Container Runtime Interface for OCI (CRI-O).

Step 5. Using CRI-O on Ubuntu 20.04

The command line tool **crioctl **can be installed via the cri-tools package.

sudo apt install cri-tools

We can now check existence of crictl Command:

$ 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?"
      }
    ]
  }
}

Pull Nginx image

$ sudo crictl pull nginx:latest
Image is up to date for docker.io/library/nginx@sha256:2834dc507516af02784808c5f48b7cbe38b8ed5d0f4837f16e78d00deb7e7767

List available images:

$ sudo crictl images
IMAGE                     TAG                 IMAGE ID            SIZE
docker.io/library/nginx   latest              c316d5a335a5c       146MB

Conclusion

That is it. We have managed to install CRI-O in Ubuntu. Enjoy using CRI-O on Ubuntu with Kubernetes.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy