docker - 无法在私有注册表中授权 Openshift 服务帐户
问题描述
我创建了一个非常简单的图像,仅用于测试:
FROM alpine:3.8
ENTRYPOINT top
我将它推送到 hub.docker.com 上的私有存储库。
我创造了秘密。我尝试了两种不同的方法,但得到了相同的结果。
oc create secret docker-registry pull-secret --docker-server=auth.docker.io/token --docker-username=MY_USER --docker-password=MY_PASS --docker-email=MY_EMAIL
或者
oc create secret generic dockerhub --from-file=.dockerconfigjson=C:\Users\USER_NAME\.docker\config.json --type=kubernetes.io/dockerconfigjson
onfig.json 文件的内容:
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "MY_USER_AND_PASS_BASE64_TOKEN",
"email": "MY_EMAIL"
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/18.03.1-ce (windows)"
},
"credsStore": "wincred"
}
我向服务帐户添加了秘密:
oc secrets link --for=pull default pull-secret
oc secrets link builder pull-secret
oc secrets link deployer pull-secret
我尝试了这样的事情:
oc secrets add serviceaccount/default secrets/pull-secret --for=pull
oc secrets add serviceaccount/builder secrets/pull-secret
oc secrets add serviceaccount/deployer secrets/pull-secret
然后,当我尝试部署图像时,openshift 显示图像可用,甚至显示图像的大小。所以,秘密工作。没有秘密,就无法访问图像。
当我尝试部署映像时,出现以下问题:
2:38:49 AM Normal Pulling pulling image "docker.io/MY_USER/simple-test-image@sha256:a9d7749ce23069865a4e540862271bv8e66f9452acb33668e72029fdfdb4e9f4"
2:38:51 AM Warning Failed Error: ErrImagePull
2 times in the last minute
2:38:51 AM Warning Failed Failed to pull image "docker.io/MY_USER/simple-test-image@sha256:a9d7749ce23069865a4e540862271bv8e66f9452acb33668e72029fdfdb4e9f4": rpc error: code = Unknown desc = repository docker.io/MY_USER/simple-test-image not found: does not exist or no pull access
2 times in the last
2:39:00 AM Normal Sandbox Changed Pod sandbox changed, it will be killed and re-created.
7 times in the last minute
2:39:02 AM Normal Back-off Back-off pulling image "docker.io/MY_USER/simple-test-image@sha256:a9d7749ce23069865a4e540862271bv8e66f9452acb33668e72029fdfdb4e9f4"
6 times in the last
2:39:02 AM Warning Failed Error: ImagePullBackOff
6 times in the last minute
系统似乎可以访问图像,但服务帐户无权访问或不使用机密。
我尝试从控制台(oc new-app docker.io/MY_USER/simple-test-image)和站点部署图像,但得到了相同的结果。
我重新创建了秘密,尝试编辑服务帐户等等,但没有任何帮助。当我将存储库的类型更改为公共时,一切正常,但我需要它是私有的。
看来我错过了什么。我将不胜感激任何建议。
解决方案
推荐阅读
- r - 使用 MatchIt 的粗化精确匹配返回错误
- go - 如何控制 gin 1.4.0+ 中缺少 URL 参数的行为?
- html - 如何在自定义 Django 模板标签中动态呈现 Vue.js 指令
- vue.js - vue js v-model 可以添加多个修饰符吗?
- python - 为什么决策树在精度和召回值上给出 100% 的准确率和整数?
- javascript - 用于汇总连接到复选框的价格的 JavaScript 函数?
- asp.net-core - ASP.NET CORE API PUT 请求获取 405 方法不允许
- c++ - 为什么我的随机函数总是未声明?
- bash - 通过ubus调用执行Openwrt UCI add_list
- python - 为什么写入文件后文件为空?