Containerd: Container Runtime

Darian Harrison Ragle
5 min readJan 12, 2021

--

During this past December 2020, many k8’s users faced issues when DockerHub registry rate limits started to kick in. Around the same time kubernetes v.1.20 became GA and officially announced deprecation for docker container runtimes scheduled for on v.1.22.

This leaves us with 2 options: Containerd and CRI-O. For now we will focus on containerd, because of its popularity, maturity, and it’s actually used inside of Docker to do all the “runtime” jobs.

By the end of this post you should get a good idea of what containerd is and how to install a k8’s master on a CentOS or Ubuntu system

What part of docker was deprecated ?

Basically, everything outside of the red box got deprecated.

Source: dev.to

More about it here: Don’t Panic: Kubernetes and Docker

Let’s zoom into Containerd

The below showcases the architecture of Containerd. Notice the Container Runtime Interface (CRI), Container Registries (Dockerhub, Quay, etc.) and Runc.

Overview:

Source: CNCF [Cloud Native Computing Foundation]

As a reminder, the CRI (plugin) will get merged into core in version 1.5

Lets zoom in again into the CRI

Source: CNCF

Notice that each container is running within a namespace and a group. To me, it is useful to think of containers as linux programs enveloped with permissions and resource managers.

  • Namespaces = linux namespaces provide isolated workspaces.
  • Cgroups = linux control groups used to allocate actual resources (memory, cpu, etc.)

Here are the man pages for the previous technologies:

Also notice how containerd is a process within systemd.

Some good and complete explanations of Containerd, namespaces and cgroups can be found in the below links:

How does this connect to Kubernetes ?

The below image shows why we need a kubelet on every host. We need to run programs, with namespace isolation, and controlled resources on each host.

The Kubelet is the main agent that runs on each worker node and ensures that containers are running in a pod. When it comes alive, the kubelet uses CRI to work with whatever runtime is present on that specific node. Kubelet fundamentally needs the runtime to:

  1. Provide image management
  2. Prepare the environment to instantiate the container
  3. Prepare the network for the pod

CRI has standardized expectations of a compatible runtime. Three of these fundamental expectations are that the runtime:

  1. Can both start and stop pods
  2. Can support operation calls — Start, Stop, Kill, Delete
  3. Provides image management from the registry

Source: Diving Deeper Into Runtimes: Kubernetes, CRI, and Shims

While not a runtime, The Shim sits between the container manager and a runtime, it is used to facilitate communications, and eliminates the long running runtime processes for containers.

The Shim allows a number of actions to take place, including the following:

  • It allows a runtime (runC) to exit after the container is started.
  • If or containerd fails, it keeps STDIO open for the container.

Source: Diving Deeper Into Runtimes: Kubernetes, CRI, and Shims

Demo:

In the following demo we cover:

  • How to set up a simple 3 node K8’s cluster on a bare-metal CentOS 7.
  • Using containerd Container Runtime.
  • Show some containerd client crt commands

Demo Videos available here:

Part 1 ( Introduction ): https://youtu.be/Ye-f5hY4RSM

Part 2 ( Set up Containerd and Kubelet): https://youtu.be/bledenNoSNI

Part 3 ( Set up Kubectl and Initialize Cluster): https://youtu.be/5NYp7CkVRxI

Code available here: https://github.com/DarianHarrison/2021_blogposts/tree/main/1.containerd

Fun Facts

Top Container Runtimes used in 2019–2020

Source: CNCF

References and Sources:

https://kubernetes.io/docs/setup/

https://github.com/opencontainers/runc

https://github.com/containerd/containerd

https://github.com/containerd/nri

https://github.com/containerd/cri

https://github.com/containernetworking/cni

https://github.com/opencontainers/runc

https://github.com/containerd/ttrpc

https://www.cncf.io/wp-content/uploads/2020/08/CNCF-Annual-Report-2019.pdf

https://sweetcode.io/getting-started-with-containerd/

https://kccnceu20.sched.com/event/ZewU

https://www.threatstack.com/blog/diving-deeper-into-runtimes-kubernetes-cri-and-shims#:~:text=CRI%20connects%20the%20kubelet%20to,present%20on%20that%20specific%20node.

https://sysdig.com/blog/sysdig-2019-container-usage-report/

https://www.datadoghq.com/container-report/

https://static.sched.com/hosted_files/kccnceu20/99/2020%20-%20Kubecon%20EU%20Introduction-containerd.pdf

https://www.threatstack.com/blog/diving-deeper-into-runtimes-kubernetes-cri-and-shims

https://www.capitalone.com/tech/cloud/container-runtime/

https://www.youtube.com/watch?v=-YnMr1lj4Z8&t=74s&ab_channel=LiveOverflow

https://www.youtube.com/watch?v=q0xt_JrJiIg&ab_channel=CNCF%5BCloudNativeComputingFoundation%5D

https://man7.org/linux/man-pages/man7/

Popular image registries (docker is default): https://www.g2.com/categories/container-registry

Some ideas to prevent to prevent DockerHub limits: How to prepare for the Docker Hub Rate Limits

Connect with me:

email: darianharrison89@gmail.com, darian.harrison@hpe.com

phone: +1 785 488 6750

--

--

No responses yet