0

我使用 Containerd 作为容器运行时。当我创建一个 pod 时,包含拉两个图像。(结果来自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

稍后,另一个图像已创建,结果来自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
sha256:294879c6444ed35b8cb94c613e61c47b9938305a1d1eaf452c0d17db471d99e5                                                                              application/vnd.docker.distribution.manifest.v2+json sha256:2cc826b775aacfb15a89a1f2d6685799f360ddb65f101b656097784cef2bb9d7 39.8 MiB  linux/amd64 io.cri-containerd.image=managed

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"}}

问题是为什么 Containerd 会拉取多个相同的图像。我希望看到一张图片,图片列表命令的输出显示拉取了 3 张图片。此外,如果我创建了很多 pod,它会因此导致磁盘压力。

4

1 回答 1

1

它不拉两个图像,它只拉一个图像。标签实际上是对它需要首先解析的特定散列的引用。所以第一个请求只是将标签解析为哈希,第二个是实际下载。

间接证据是两者之间的时间很短,您可以看到只花了 0.002 秒就收到了对第一个请求的回复,然后才开始下载。

于 2021-06-07T07:52:18.233 回答