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:
- Runtime: runc (or any OCI runtime-spec implementation) and oci runtime tools
- Images: Image management using containers/image
- Storage: Storage and management of image layers using containers/storage
- Networking: Networking support through use of CNI
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.
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 -y full-upgrade
It is recommended to reboot your system to ensure it is running on updated version.
[ -f /var/run/reboot-required ] && sudo reboot -f
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.28, install CRI-O version 1.28. 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.28
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.28
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 package
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 y 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:
$ crio --version
crio version 1.28.4
Version: 1.28.4
GitCommit: unknown
GitCommitDate: unknown
GitTreeState: clean
BuildDate: 2024-04-10T20:59:38Z
GoVersion: go1.19
Compiler: gc
Platform: linux/amd64
Linkmode: dynamic
BuildTags:
apparmor
seccomp
containers_image_ostree_stub
exclude_graphdriver_btrfs
exclude_graphdriver_devicemapper
containers_image_openpgp
LDFlags: -s -w -X github.com/cri-o/cri-o/internal/version.buildDate=2024-04-10T20:59:38Z
SeccompEnabled: true
AppArmorEnabled: true
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 Wed 2024-04-17 08:43:11 UTC; 2min 7s ago
Docs: https://github.com/cri-o/cri-o
Main PID: 3814 (crio)
Tasks: 7
Memory: 9.7M
CPU: 190ms
CGroup: /system.slice/crio.service
└─3814 /usr/bin/crio
....
Step 4: Using CRI-O on Ubuntu
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/nginx@sha256:c870bf53de0357813af37b9500cb1c2ff9fb4c00120d5fe1d75c21591293c34d
$ sudo crictl pull hello-world
Image is up to date for docker.io/library/hello-world@sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
$ sudo crictl pull busybox
Image is up to date for docker.io/library/busybox@sha256: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<<EOF
{
"metadata": {
"name": "nginx-container",
"attempt": 1
},
"image": {
"image": "nginx"
},
"log_path": "nginx.log",
"linux": {
"security_context": {
"namespace_options": {}
}
}
}
EOF
cat >net-pod.json<<EOF
{
"metadata": {
"name": "networking",
"uid": "networking-pod-uid",
"namespace": "default",
"attempt": 1
},
"hostname": "networking",
"port_mappings": [
{
"container_port": 80
}
],
"log_directory": "/tmp/net-pod",
"linux": {}
}
EOF
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. If you want to master Kubernetes administration, checkout the books below.
For installation of CRI-O on CentOS Linux, refer to: