kubernetes 即使图像摘要已存在于节点上,Kubelet也会提取图像

5gfr0r5j  于 2022-11-21  发布在  Kubernetes
关注(0)|答案(2)|浏览(93)

我在Pod中运行了一个小脚本,它在我的注册表中查找最新的应用程序映像(dashboard:development),然后将它们推送到正在运行的节点(通过守护进程)。
这个确实有效,如下所示。
现在,我假设一旦一个应用程序pod(比如sp-pod-xx)请求这个图像,即使设置了imagePullPolicy: Always,kubelet也不应该尝试重新拉取图像。

**总是:**每次Kubelet启动容器时,Kubelet都会查询容器映像注册表,将名称解析为映像摘要。如果Kubelet有一个容器映像在本地缓存了该摘要,则Kubelet会使用其缓存的映像;否则,Kubelet拉取具有解析的摘要的映像,并使用该映像来启动容器。

但是,即使摘要是相同的(我已经验证了这一点),kubelet仍然会重新提取图像。
知道为什么吗?
事件记录档:

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

zlwx9yxi1#

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

ajsxfq5m

ajsxfq5m2#

使用映像提取策略:如果单元规范中不存在,则使用节点上已存在的映像。
使用映像提取策略:始终从映像注册表中提取新映像。

相关问题