考察私有镜像仓库认证。
根因:默认 ServiceAccount 没有私有仓库的登录凭证,拉镜像被 401 拒绝。
修复步骤:
kubectl create secret docker-registry regcred --docker-server=registry.example.com --docker-username=xxx --docker-password=xxx [email protected]spec:
imagePullSecrets:
- name: regcred
containers:
- name: app
image: registry.example.com/team/app:v1
imagePullSecrets 实现默认挂载,免去每个 Pod 声明。排查:describe pod 的 Events 看是 unauthorized(凭证错)还是 manifest unknown(镜像 tag 不存在)/ registry rate limit(匿名拉取限流),三者修复方式不同。
题目与答案就在本页;收藏、批注和错题重练在应用内