我有一個在 Pod 中運行的小腳本,它dashboard:development在我的注冊表中查找最新的應用程式影像 (),然后將它們推送到正在運行的節點(通過守護程式集)。
這確實有效,如下所示。
現在,我假設一旦 App pod(如sp-pod-xx)請求此影像,kubelet 不應嘗試重新拉取影像,即使imagePullPolicy: Always已設定。正如檔案所說,kubelet 比較摘要并僅在不匹配時拉取:
Always: 每次 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"}
uj5u.com熱心網友回復:
檔案是錯誤的。您可以在此處閱讀源代碼。該策略PullIfNotPresent將檢查影像是否存在,但會Always直接跳到拉取影像。
uj5u.com熱心網友回復:
在 pod 規范中使用 imagePullPolicy: IfNotPresent。利用節點上已經存在的影像。
使用 imagePullPolicy: Always 從鏡像注冊表中拉取新鏡像。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/535574.html
