取值与默认
| 取值 | 行为 | 何时为默认 |
|---|---|---|
| IfNotPresent | 本地有则不再拉取 | 镜像 tag 非 latest(含指定 tag/digest) |
| Always | 每次启动都拉取 | 镜像 tag 为 latest 或省略 tag |
| Never | 只用本地镜像 | 从不默认,需显式设置 |
显式声明与排查
显式声明与排查
kubectl get deploy web -o jsonpath='{.spec.template.spec.containers[*].imagePullPolicy}'
kubectl describe pod web-x | grep -i -A2 'Image'
kubectl get events --field-selector reason=Failed生产环境建议明确写 imagePullPolicy 并用固定版本 tag 或 digest,行为可预期。