我在从GCR中提取图像(由我的部署提取(时遇到问题我得到ImagePullBackOff错误。
我已经一步一步地学习了本教程。
https://container-solutions.com/using-google-container-registry-with-kubernetes/
然而,它似乎对我不起作用。我甚至尝试在创建服务帐户密钥时使用存储管理员角色,但仍然没有用。
在描述吊舱时,我得到了这个错误:
Warning Failed 14s (x2 over 30s) kubelet, docker-for-desktop Failed to pull image "gcr.io/<project-name>/<image-name>": rpc error: code = Unknown desc = Error response from daemon: Get https://gcr.io/v2/<project-name>/<image-name>/manifests/latest: unknown: Unable to parse json key.
Warning Failed 14s (x2 over 30s) kubelet, docker-for-desktop Error: ErrImagePull
Normal BackOff 2s (x3 over 29s) kubelet, docker-for-desktop Back-off pulling image "gcr.io/<project-name>/<image-name>"
Warning Failed 2s (x3 over 29s) kubelet, docker-for-desktop Error: ImagePullBackOff
访问时https://gcr.io/v2/项目名称/图像名称>清单/最新url,我得到了这个:
// 20181124152036
// https://gcr.io/v2/project-name/image-name/manifests/latest
{
"errors": Array[1][
{
"code": "UNAUTHORIZED",
"message": "You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication"
}
]
}
吊舱定义:
apiVersion: apps/v1
kind: Deployment
metadata:
name: microservice-1-deployment
spec:
replicas: 3
selector:
matchLabels:
app: microservice-1
template:
metadata:
labels:
app: microservice-1
spec:
containers:
- name: microservice-1
image: gcr.io/project-name/image-name
ports:
- containerPort: 80
注意:
我的部署能够在docker hub上托管时提取图像,问题只发生在GCR中提取图像时。
环境
- Windows 10
- Docker版本2.0.0.0-win78(28905(
- Kubernetes 1.10.3(包含在桌面docker中(
,我希望你能帮我
提前感谢
OK找到了罪魁祸首,这与Powershell和命令提示符有关。
我切换到使用GitBash,并遵循本教程中的相同说明
https://container-solutions.com/using-google-container-registry-with-kubernetes/
它成功了!
罪魁祸首可能发生在Powershell和/或命令提示符上创建imagePullSecrets时。读取json文件时可能出现了与编码或其他内容有关的问题。
希望这能帮助到任何人。
查看错误消息,您提供的json文件似乎存在unable to parse json file
问题
这背后的原因是您的json文件中有break(newline
(,因此无法秘密识别。
请看一下这里,然后尝试其中一种解决方案。您可以随时选择此处列出的其他身份验证方法
Docker登录Powershell 中的gcr.io
希望这能有所帮助。