我有一个 scala 应用程序。我已将 docker 镜像推送到私有(private)注册表中。现在,据我了解,我需要创建一个 secret 来使用 yaml 文件从私有(private)存储库中提取图像。
我使用以下命令创建了一个 secret :
kubectl create secret docker-registry regsecret --docker-username=token --docker-password=<private repo password> --docker-email=<email id which I use to access the private repo>
这成功地创建了一个 secret 。
图像现在被推送到
镜像名称为“imagecheck”,repo 名称为“repocheck”。
现在,当我尝试从我的 yaml 文件中提取图像时,它给出了一个错误提示
Failed to pull image "abc.somerepo.com/repocheck/imagecheck:latest": image pull failed for abc.somerepo.com/repocheck/imagecheck:latest, this may be because there are no credentials on this request
这是我的 yaml 文件:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: onlinescoring
spec:
replicas: 4 # tells deployment to run 2 pods matching the template
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 0
template: # create pods using pod definition in this template
metadata:
labels:
app: online1
spec:
containers:
- name: cont1
image: abc.somerepo.com/repocheck/imagecheck:latest
ports:
- containerPort: 32014
imagePullSecrets:
- name: regsecret
我能够从我的终端中提取图像。请指导如何解决错误。
提前致谢!
最佳答案
使用以下命令删除 secret 并重新创建:
kubectl create secret docker-registry regsecret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=token --docker-password=<private repo password> --docker-email=<email id which I use to access the private repo>
替换
DOCKER_REGISTRY_SERVER
带有私有(private)注册表 url。默认值:
https://index.docker.io/v1/
关于docker - Kubernetes - 从私有(private) Docker 注册表中提取时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42522503/