cotainerd
Installing Containerd, runc, and CNI on Ubuntu VMs for Kubernetes Nodes
More details can be found form https://github.com/containerd/containerd/blob/main/docs/getting-started.md
In this guide, you will learn how to install containerd, runc, and CNI plugins on Ubuntu virtual machines, and verify the setup by pulling and running a Redis image. Additionally, you will install nerdctl to manage images and containers.
Step 1: Update System Packages
First, update the system packages and install necessary dependencies:
sudo apt update
sudo apt install -y curl gnupg2 software-properties-commonStep 2: Install Containerd
Install containerd:
sudo apt install -y containerdConfigure containerd:
Create the default configuration file:
sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.tomledit the configuration file:
vi /etc/containerd/config.tomlset SystemdCgroup to true in the plugins.cri.containerd.runtimes.runc.options section:
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
...
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = trueIn case network issue
sudo mkdir -p /etc/systemd/system/containerd.service.d
sudo vi /etc/systemd/system/containerd.service.d/http-proxy.conf[Service]
Environment="HTTP_PROXY=http://192.168.137.1:7890"
Environment="HTTPS_PROXY=http://192.168.137.1:7890"
Environment="NO_PROXY=localhost"Restart and enable the containerd service:
sudo systemctl daemon-reload
sudo systemctl restart containerd
sudo systemctl start containerd
sudo systemctl enable containerd
sudo systemctl status containerdStep 3: Install runc
Download and install runc:
sudo apt install -y runcStep 4: Install CNI Plugins
Download and install CNI plugins:
sudo mkdir -p /opt/cni/bin
curl -L https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz | sudo tar -C /opt/cni/bin -xzStep 5: Verify Containerd Setup
Use ctr (the CLI tool for containerd) to pull the Redis image:
sudo ctr image pull docker.io/library/redis:latestCheck if the Redis image was successfully pulled:
sudo ctr image ls | grep redisStep 6: Install Nerdctl
nerdctl is a Docker-compatible CLI for managing containerd containers.
Download and install nerdctl:
sudo curl -L https://github.com/containerd/nerdctl/releases/download/v1.2.0/nerdctl-1.2.0-linux-amd64.tar.gz | sudo tar -C /usr/local/bin -xzVerify that nerdctl was installed successfully:
nerdctl --versionStep 7: Verify Nerdctl Setup
Use nerdctl to pull the Redis image (optional, skip if already pulled using ctr):
sudo nerdctl pull redis:latestCheck if the Redis image was successfully pulled:
sudo nerdctl images | grep redisUse nerdctl to run a Redis container:
sudo nerdctl run -d --name redis-server -p 6379:6379 redis:latestCheck if the container is running:
sudo nerdctl psVerify that the Redis service is accessible:
redis-cli -h 127.0.0.1 -p 6379 pingExpected output:
PONGEnsure All Nodes Are Properly Configured Repeat the above steps on each Kubernetes node to ensure they can all properly use images to start services.
Conclusion
By following these steps, you have successfully installed containerd and its related components (runc and CNI) on your Ubuntu VMs. You verified the setup by pulling and running a Redis image, and installed nerdctl to manage images and containers. These configurations and validations ensure that each node can properly use images to start services, laying the groundwork for your Kubernetes cluster deployment.