Containerd pull multiple images while creating a Pod in Kubernetes

6/3/2021

I am using Containerd as a container runtime. When I create a pod, contained pull two images. (the result from ctr -n k8s.io i ls -q)

myprivateregistery/gcr.io/google_containers/kubernetes-dashboard-amd64:v1.7.1                                                                  application/vnd.docker.distribution.manifest.v2+json sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 39.8 MiB  linux/amd64 io.cri-containerd.image=managed
myprivateregistery/gcr.io/google_containers/kubernetes-dashboard-amd64@sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 application/vnd.docker.distribution.manifest.v2+json sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 39.8 MiB  linux/amd64 io.cri-containerd.image=managed

A bit later another image has created, the result from ctr -n k8s.io i ls -q becomes.

myprivateregistery/gcr.io/google_containers/kubernetes-dashboard-amd64:v1.7.1                                                                  application/vnd.docker.distribution.manifest.v2+json sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 39.8 MiB  linux/amd64 io.cri-containerd.image=managed
myprivateregistery/gcr.io/google_containers/kubernetes-dashboard-amd64@sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 application/vnd.docker.distribution.manifest.v2+json sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 39.8 MiB  linux/amd64 io.cri-containerd.image=managed
sha256:294879c6444ed35b8cb94c613e61c47b9938305a1d1eaf452c0d17db471d99e5                                                                              application/vnd.docker.distribution.manifest.v2+json sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 39.8 MiB  linux/amd64 io.cri-containerd.image=managed

The events received by Containerd:

2021-06-03 10:41:41.942185302 +0000 UTC k8s.io /images/create {"name":"myprivateregistry/gcr.io/google_containers/kubernetes-dashboard-amd64:v1.7.1"}
2021-06-03 10:41:41.944191919 +0000 UTC k8s.io /images/create {"name":"sha256:294879c6444ed35b8cb94c613e61c47b9938305a1d1eaf452c0d17db471d99e5","labels":{"io.cri-containerd.image":"managed"}}

The question is why Containerd pull mutilple images that are the same. I exepect to see one image, the output of image listing command shows 3 images pulled. Also if I created lot of pod it result a Disk pressure beacause of this.

-- mohamed.Yassine.SOUBKI
containerd
kubernetes

1 Answer

6/7/2021

It doesn't pull two images, it only pulls one images. The tag is actually a reference to a specific hash that it needs to resolve first. So the first requests is just to resolve the tag to the hash and the second is the actual download.

Indirect evidence for that is the small amount of time between the two, you can see that it only took 0.002 seconds to get the reply to the first request and only after that it began downloading.

-- Tim Stoop
Source: StackOverflow