为什么 kubelet 不断重新拉取镜像

问题描述 投票:0回答:1

根据文档,它应该仅在图像更改时重新拉取,并且图像已经存在 1 个月了,尽管我看到它正在定期拉取,以防止 pod (detect) 启动:

cam989-detect-d4fc6695b-bpc2x      0/1     ImagePullBackOff         0               6m53s
pipel161-analyz-7f49fff557-pdcn5   0/1     Terminating              0               14m
lh-pgadmin-5b598d4d4-zc79q         1/1     Running                  0               14m

部署.yml:

     containers:       
      - image: registry.dev.mpksoft.ru/lighthouse/lh-detector/lh-detector:current
        imagePullPolicy: Always
        name: ${PIPELINE}-detect

Kubernetes 文档:

Always
every time the kubelet launches a container, the kubelet queries the container image registry to resolve the name to an image digest. If the kubelet has a container image with that exact digest cached locally, the kubelet uses its cached image; otherwise, the kubelet pulls the image with the resolved digest, and uses that image to launch the container.
linux kubernetes docker-registry kubelet
1个回答
0
投票

正如 kubernetes 官方文档中关于 Image Pull 策略中提到的:

  • 始终:始终从存储库中提取映像。

  • IfNotPresent:如果本地尚未存在,则拉取图像。

如果缓存的图像已经存在,但正如您使用的那样

<image-name\>:<tag\>,
kubelet 将始终尝试拉取图像,这就是 kubelet 不断重新拉取图像的原因。

对于您的问题,有一个解决方法,您可以尝试并在上述文档的帮助下告诉我这是否有效。

为了确保 Pod 始终使用相同版本的容器镜像,您可以指定镜像的摘要;将

<image-name\>:<tag\>
替换为
<image-name\>@<digest\>
(例如,image@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2)。

所以尝试使用摘要并使用

imagePullPolicy: IfNotPresent
,这将确保您的图像不会再次被拉取并且也使用相同的版本。

© www.soinside.com 2019 - 2024. All rights reserved.