我怎样才能拉docker.pkg.github.com
来自 Kubernetes 集群内的 Docker 镜像?
目前,Github Docker 注册表甚至需要对来自公共 Github 存储库的包进行身份验证。
- 创建新的 Github 个人访问令牌
read:packages
范围在https://github.com/settings/tokens/new https://github.com/settings/tokens/new.
-
Base-64 编码<your-github-username>:<TOKEN>
, ie.:
$ echo -n VojtechVitek:4eee0faaab222ab333aa444aeee0eee7ccc555b7 | base64
<AUTH>
注意:确保不要在字符串末尾编码换行符。
-
创建 kubernetes.io/dockerconfigjson 秘密
A)手动创建秘密:
$ echo '{"auths":{"docker.pkg.github.com":{"auth":"<AUTH>"}}}' | kubectl create secret generic dockerconfigjson-github-com --type=kubernetes.io/dockerconfigjson --from-file=.dockerconfigjson=/dev/stdin
B) 或者,创建可用于的 .yml 文件kubectl apply -f
:
kind: Secret
type: kubernetes.io/dockerconfigjson
apiVersion: v1
metadata:
name: dockerconfigjson-github-com
stringData:
.dockerconfigjson: {"auths":{"docker.pkg.github.com":{"auth":"<AUTH>"}}}
GitOps 注意事项:我强烈建议不要将上述文件以纯文本形式存储在 git 存储库中。水合 CD 管道中的价值或使用类似工具加密/密封文件https://github.com/mozilla/sops https://github.com/mozilla/sops or https://github.com/bitnami-labs/sealed-secrets https://github.com/bitnami-labs/sealed-secrets.
-
现在,您可以通过以下方式从 pod 的规范定义中引用上述秘密imagePullSecrets
field:
spec:
containers:
- name: your-container-name
image: docker.pkg.github.com/<ORG>/<REPO>/<PKG>:<TAG>
imagePullSecrets:
- name: dockerconfigjson-github-com
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)