Install CRI-O Container Runtime on Ubuntu 22.04|20.04|18.04

Posted on 236 views

This guide will walk you through the installation of CRI-O Container Runtime on Ubuntu 22.04|20.04|18.04. CRI-O is an OCI-based implementation of Kubernetes Container Runtime Interface (CRI) designed to provide an integration path between OCI conformant runtimes and the kubelet.

CRI-O is created to provide following core functionalities:

  • Support multiple image formats including the existing Docker image format
  • Support for multiple means to download images including trust & image verification
  • Container image management (managing image layers, overlay filesystems, etc)
  • Container process lifecycle management
  • Monitoring and logging required to satisfy the CRI
  • Resource isolation as required by the CRI

The libraries used by CRI-O are:

Install CRI-O Container Runtime on Ubuntu 22.04|20.04|18.04

We will use pre-built binary packages to install CRI-O container runtime. Follow the steps below to install CRI-O Container Runtime on Ubuntu 22.04|20.04|18.04.

Step 1: Update System

Ensure your Ubuntu system is updated. If you’re afraid this could break your system you can skip.

sudo apt update && sudo apt upgrade

It is recommended to reboot your system to ensure it is running on updated version.

sudo systemctl reboot

Step 2: Add CRI-O Kubic repository

Add the Kubic repository which host binary packages for Debian based systems. If using CRI-O with Kubernetes, install the version matching Kubernetes version you’ll setup.

If your Kubernetes version is 1.23, install CRI-O version 1.23. We’ll start by adding the APT repository which contains CRI-O packages:

Ubuntu 22.04/20.04:

OS=xUbuntu_20.04
CRIO_VERSION=1.23
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list

Ubuntu 18.04:

OS=xUbuntu_18.04
CRIO_VERSION=1.23
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list

Once the repository is added to your system, import GPG key:

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

Step 3: Install CRI-O on Ubuntu22.04|20.04|18.04

When repository is added, update apt cache and install CRI-O on Ubuntu.

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

Accept installation prompt with key.

The following additional packages will be installed:
  conmon containers-common
Suggested packages:
  cri-o-runc | runc containernetworking-plugins
The following NEW packages will be installed:
  conmon containers-common cri-o
0 upgraded, 3 newly installed, 0 to remove and 94 not upgraded.
Need to get 20.2 MB of archives.
After this operation, 99.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Checking the version of CRI-O installed on Ubuntu:

$ apt show cri-o
Package: cri-o
Version: 1.23.0~0
Priority: optional
Section: devel
Maintainer: Peter Hunt 
Installed-Size: 98.3 MB
Depends: libgpgme11, libseccomp2, conmon, containers-common (>= 0.1.27), tzdata
Suggests: cri-o-runc | runc (>= 1.0.0), containernetworking-plugins
Replaces: cri-o-1.19, cri-o-1.20, cri-o-1.21
Homepage: https://github.com/cri-o/cri-o
Download-Size: 19.9 MB

Start and enable crio service:

sudo systemctl enable crio.service
sudo systemctl start crio.service

Service status can be checked with the command:

$ 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 Sun 2020-06-07 20:16:50 CEST; 37s ago
       Docs: https://github.com/cri-o/cri-o
   Main PID: 2461 (crio)
      Tasks: 13
     Memory: 7.7M
     CGroup: /system.slice/crio.service
             └─2461 /usr/bin/crio

Jun 07 20:16:50 ubuntu systemd[1]: Starting Container Runtime Interface for OCI (CRI-O)...
Jun 07 20:16:50 ubuntu systemd[1]: Started Container Runtime Interface for OCI (CRI-O).

Step 4: Using CRI-O on Ubuntu22.04|20.04|18.04

The command line tool crioctl can be installed through cri-tools package.

sudo apt install cri-tools

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: Missing CNI default network"
      
    ]
  

Pull a test image:

$ sudo crictl pull nginx
Image is up to date for docker.io/library/[email protected]:c870bf53de0357813af37b9500cb1c2ff9fb4c00120d5fe1d75c21591293c34d

$ sudo crictl pull hello-world
Image is up to date for docker.io/library/[email protected]:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1

$ sudo crictl pull busybox
Image is up to date for docker.io/library/[email protected]:95cf004f559831017cdf4628aaf1bb30133677be8702a8c5f2994629f637a209

List available images:

$ sudo crictl images
IMAGE                           TAG                 IMAGE ID            SIZE
docker.io/library/alpine        latest              a24bb4013296f       5.85MB
docker.io/library/busybox       latest              1c35c44120825       1.44MB
docker.io/library/hello-world   latest              bf756fb1ae65a       20kB
docker.io/library/nginx         latest              4392e5dad77db       136MB

Create pod sandbox config file:

cat >nginx.json<net-pod.json<

Run the pod

sudo crictl runp net-pod.json
sudo crictl create nginx.json net-pod.json
sudo crictl ps -a

Enjoy using CRI-O on Ubuntu with Kubernetes.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.