Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does Kubernetes migrate from Docker to Containerd

Shulou Source: shulou.com Published: 2022-05-31 20:23:32 09月17日 Update

This article mainly explains "how Kubernetes migrates from Docker to Containerd". The explanation in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "how Kubernetes migrates from Docker to Containerd".

Kubernetes no longer uses Docker as a container runtime after version 1.20. Don't panic? the Docker container is still supported, but the layer between dockershim/Docker Kubernetes and containerd has been deprecated and will be removed from version 1.22 +. Therefore, if you are running docker, you need to change to the supported container runtime interface (CRI). Containerd is a good choice, and if you are running Docker, it is already running on the Kubernetes node.

One obvious advantage is less overhead and no Docker-shim and Docker translation layer, as shown in the figure.

How to migrate from docker shim to containerd CRI

First, we check what the currently running container is. We use kubectl get node-o to do this. As we can see, we run Docker as a runtime.

Now, let's check to see if containerd cli / usr/bin/ctr exists, and the namespace moby exists. The command: / usr/bin/ctr namespace list moby is the namespace of docker. We can list the running containers in this namespace

If all goes well, we can change the cri, one node at a time, first the working node, then the control node. If there is only one control node, you will lose access to the cluster, which will be temporary and should recover itself.

Expelling node

We need to block and release the nodes in order to reschedule the workload.

Stop service and delete docker (optional)

We deleted Docker, which is unnecessary, but it will make things clearer and less prone to mistakes in the future. We will save some disk space.

Containerd configuration

Disable the disabled_plugins line in / etc/containerd/config. So the cri interface loads

If containerd does not have a configuration file, you can generate a new default file.

Restart containerd

Systemctl restart containerd

Change runtime

Edit the / var/lib/kubelet/kubeadm-flags.env file; and add the containerd runtime to the tag. -- container-runtime=remote and-- container-runtimeendpoint=unix:///run/containerd/containerd.sock, so the kubeadm-flags file should look like this.

/ var/lib/kubelet/kubeadm-flags.env starts kubelet

After changing the runtime, we can start the kubelet service

Systemctl start kubelet

Check

Now, when we run kubectl, kubectl get nodes-o wide, we see that containerd is the runtime containerd of the node we just changed.

The node we just changed is still blocked. So we can lift the blockade now.

If you check the namespace on the node now, you will see a new namespace k8s.io. The moby namespace is now empty, there are no containers running in this namespace, and all containers are now running k8.io namespaces.

View new k8s.io containerd namespace

We have successfully changed the cri, and now we can move to the next node and repeat everything.

Thank you for your reading, the above is the content of "how Kubernetes migrates from Docker to Containerd". After the study of this article, I believe you have a deeper understanding of how Kubernetes migrates from Docker to Containerd, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Run node space container name file being learning blocking checking content interface version work control support service configuration obvious clear Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS Xiaomi Apple OPPO Reno