我创建了注册点数,并且当我像这样在pod上申请时:
apiVersion: v1
kind: Pod
metadata:
name: private-reg
spec:
containers:
- name: private-reg-container
image: registry.io.io/simple-node
imagePullSecrets:
- name: regcred
它能成功绘制图像
但是,如果我尝试这样做:
apiVersion: apps/v1
kind: Deployment
metadata:
name: node123
namespace: node123
spec:
replicas: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2
maxUnavailable: 0
selector:
matchLabels:
name: node123
template:
metadata:
labels:
name: node123
spec:
containers:
- name: node123
image: registry.io.io/simple-node
ports:
- containerPort: 3000
imagePullSecrets:
- name: regcred
在pod上将收到错误消息:ImagePullBackOff
当我描述它越来越
无法提取图像“ registry.io.io/简单节点”:rpc错误:代码= 未知的desc =来自守护程序的错误响应:获取 https://registry.io.io/v2/simple-node/manifests/latest:没有基本身份验证 凭据
有人知道如何解决这个问题吗?
答案 0 :(得分:4)
我们始终从私有注册表运行映像。这个清单可能会帮助您:
将您的参数放入终端的env变量中,以获取真实的唯一来源:
export DOCKER_HOST=registry.io.io
export DOCKER_USER=<your-user>
export DOCKER_PASS=<your-pass>
确保您可以进行身份验证并且图像确实存在
echo $DOCKER_PASS | docker login -u$DOCKER_USER --password-stdin $DOCKER_HOST
docker pull ${DOCKER_HOST}/simple-node
确保您在pod / deployment的相同命名空间中创建了Dockerconfig机密;
namespace=mynamespace # default
kubectl -n ${namespace} create secret docker-registry regcred \
--docker-server=${DOCKER_HOST} \
--docker-username=${DOCKER_USER} \
--docker-password=${DOCKER_PASS} \
--docker-email=anything@will.work.com
使用秘密对Pod使用的服务帐户进行修补
namespace=mynamespace
kubectl -n ${namespace} patch serviceaccount default \
-p '{"imagePullSecrets": [{"name": "regcred"}]}'
# if the pod use another service account,
# replace "default" by the relevant service account
或
在窗格中添加imagePullSecrets
:
imagePullSecrets:
- name: regcred
containers:
- ....