Kubelet提取图像,即使图像摘要已经存在于Node上



我有一个小脚本在Pod中运行,它在我的注册表中插入最新的应用程序映像(dashboard:development),然后将它们推送到正在运行的节点(通过守护进程)。

Thisdoes work,如下所示。

现在,我假设一旦App pod(如sp-pod-xx)请求此图像,kubelet不应该尝试重新拉取图像,即使设置了imagePullPolicy: Always。正如文档所说,kubelet比较摘要,如果不匹配,则只提取:

总是

:每次kubelet启动容器时,kubelet都会查询容器映像注册表以将名称解析为映像摘要。如果kubelet有一个容器映像,它的摘要在本地缓存,那么kubelet使用它的缓存映像;否则,kubelet将提取具有解析摘要的映像,并使用该映像启动容器。

但是,即使摘要是相同的(我确实验证了这一点),kubelet仍然重新提取图像。App pod和Daemonset pod也在同一个节点上运行。

知道为什么吗?

事件日志:

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

版本:

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

文档是错误的。您可以在这里阅读源代码。策略PullIfNotPresent将检查图像是否存在,但是Always直接跳过拉取图像。

在pod规范中使用imagepulpolicy: IfNotPresent来利用节点上已经存在的图像。

使用imagePullPolicy: Always从图像注册表中提取新图像。

相关内容

  • 没有找到相关文章

最新更新