[英]Kubelet pulls image even though image digest is already present on Node
I have a small script running in a Pod that pokes for the latest App images ( dashboard:development
) in my registry and then pushes them to the Nodes running (via a daemonset).我有一个在 Pod 中运行的小脚本,它在我的注册表中查找最新的应用程序图像 ( dashboard:development
),然后将它们推送到正在运行的节点 (通过 daemonset)。
This does work , as seen below.这确实有效,如下所示。
Now, I would assume that once an App pod (like sp-pod-xx
) requests this image, kubelet should not try to re-pull the image, even if imagePullPolicy: Always
is set.现在,我假设一旦 App pod(如sp-pod-xx
)请求此图像,kubelet 不应尝试重新拉取图像,即使设置了imagePullPolicy: Always
。 As the docs say, kubelet compares the digest and only pulls, if there is a mismatch:正如文档所说,kubelet 比较摘要并仅在不匹配时拉取:
Always: every time the kubelet launches a container, the kubelet queries the container image registry to resolve the name to an image digest. Always:每次 kubelet 启动容器时,kubelet 都会查询容器镜像注册表以将名称解析为镜像摘要。 If the kubelet has a container image with that exact digest cached locally, the kubelet uses its cached image;如果 kubelet 有一个容器镜像,其中在本地缓存了准确的摘要,则 kubelet 将使用其缓存的镜像; otherwise, the kubelet pulls the image with the resolved digest, and uses that image to launch the container.否则,kubelet 会拉取带有已解析摘要的镜像,并使用该镜像启动容器。
But, even though the digests are identical (I did verify this), kubelet still re-pulls the image anyway.但是,即使摘要是相同的(我确实验证了这一点),kubelet 仍然会重新拉取图像。 The App pod and the Daemonset pods are running on the same nodes too. App pod 和 Daemonset pod 也在相同的节点上运行。
Any idea why?知道为什么吗?
Event logs:事件日志:
4m5s Normal Killing pod/image-puller-ds-ldbfz
3m57s Normal SuccessfulCreate daemonset/image-puller-ds Created pod: image-puller-ds-fcmts
3m57s Normal SuccessfulCreate daemonset/image-puller-ds Created pod: image-puller-ds-fhhds
3m57s Normal Pulled pod/image-puller-ds-fhhds Successfully pulled image "dashboard:development" in 192.717161ms
3m57s Normal Pulling pod/image-puller-ds-fhhds Pulling image "dashboard:development"
3m56s Normal Started pod/image-puller-ds-fhhds Started container image-puller
3m56s Normal Created pod/image-puller-ds-fcmts Created container image-puller
3m56s Normal Created pod/image-puller-ds-fhhds Created container image-puller
3m56s Normal Started pod/image-puller-ds-fcmts Started container image-puller
3m56s Normal Pulled pod/image-puller-ds-fhhds Container image "pause:0.0.1" already present on machine
3m55s Normal Created pod/image-puller-ds-fcmts Created container pause
3m55s Normal SuccessfulDelete daemonset/image-puller-ds Deleted pod: image-puller-ds-xt9vv
3m55s Normal Pulled pod/image-puller-ds-fcmts Container image "pause:0.0.1" already present on machine
3m55s Normal Created pod/image-puller-ds-fhhds Created container pause
3m55s Normal Started pod/image-puller-ds-fhhds Started container pause
3m55s Normal Started pod/image-puller-ds-fcmts Started container pause
3m55s Normal Killing pod/image-puller-ds-xt9vv Stopping container pause
3m54s Normal Killing pod/image-puller-ds-wgwzh Stopping container pause
3m54s Normal SuccessfulDelete daemonset/image-puller-ds Deleted pod: image-puller-ds-wgwzh
3m25s Normal Pulling pod/sp-pod-f3884032-1164-48e8-8213-c0c3856e573d Pulling image "dashboard:development"
3m25s Normal Pulled pod/sp-pod-f3884032-1164-48e8-8213-c0c3856e573d Successfully pulled image "dashboard:development" in 220.610781ms
3m25s Normal Created pod/sp-pod-f3884032-1164-48e8-8213-c0c3856e573d Created container sp-container-f3884032-1164-48e8-8213-c0c3856e573d
3m25s Normal Started pod/sp-pod-f3884032-1164-48e8-8213-c0c3856e573d Started container sp-container-f3884032-1164-48e8-8213-c0c3856e573d
Versions:版本:
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.0", GitCommit:"c2b5237ccd9c0f1d600d3072634ca66cefdf272f", GitTreeState:"clean", BuildDate:"2021-08-04T18:03:20Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.12", GitCommit:"f941a31f4515c5ac03f5fc7ccf9a330e3510b80d", GitTreeState:"clean", BuildDate:"2022-11-09T17:12:33Z", GoVersion:"go1.17.13", Compiler:"gc", Platform:"linux/amd64"}
The docs are wrong.文档是错误的。 You can read the source code here .您可以在此处阅读源代码。 The policy PullIfNotPresent
would check if the image exists, but Always
skips directly to pulling the image. PullIfNotPresent
策略会检查图像是否存在,但Always
直接跳到拉取图像。
Use imagePullPolicy: IfNotPresent in the pod spec.在 pod 规范中使用 imagePullPolicy: IfNotPresent。 to utilize the image that is already present on the node.利用节点上已经存在的图像。
Use imagePullPolicy: Always to pull fresh image from image registry.使用 imagePullPolicy: Always 从镜像注册表中拉取新镜像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.