Voj*_*tek 9 github kubernetes docker-registry
如何docker.pkg.github.com从 Kubernetes 集群中提取Docker 镜像?
目前,Github Docker 注册表甚至需要对来自公共 Github 存储库的包进行身份验证。
Voj*_*tek 18
read:packages在https://github.com/settings/tokens/new 上创建具有范围的新 Github 个人访问令牌。Base-64 编码<your-github-username>:<TOKEN>,即:
$ echo -n VojtechVitek:4eee0faaab222ab333aa444aeee0eee7ccc555b7 | base64
<AUTH>
Run Code Online (Sandbox Code Playgroud)
注意:确保不要在字符串末尾编码换行符。
创建 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
Run Code Online (Sandbox Code Playgroud)
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>"}}}
Run Code Online (Sandbox Code Playgroud)
GitOps 注意事项:我强烈建议不要将上述文件以纯文本形式存储在您的 git 存储库中。水化 CD 管道中的值或使用https://github.com/mozilla/sops或https://github.com/bitnami-labs/sealed-secrets等工具加密/密封文件。
现在,您可以通过imagePullSecrets字段从 pod 的规范定义中引用上述机密:
spec:
containers:
- name: your-container-name
image: docker.pkg.github.com/<ORG>/<REPO>/<PKG>:<TAG>
imagePullSecrets:
- name: dockerconfigjson-github-com
Run Code Online (Sandbox Code Playgroud)Mor*_*rty 10
我必须从 docker.pkg.github.com 迁移到 ghcr.io 才能使其与 containerd 一起使用:https ://docs.github.com/en/packages/working-with-a-github-packages-registry/从 docker-registry 迁移到container-registry
不要忘记使用以下命令创建令牌read:packages:
kubectl create secret docker-registry dockerconfigjson-github-com \
--dry-run=true \
--docker-server=https://docker.pkg.github.com \
--docker-username=<username> \
--docker-password=<https://github.com/settings/tokens/new> \
--namespace=default -o yaml
Run Code Online (Sandbox Code Playgroud)
添加拉秘密:
spec:
containers:
- name: your-container-name
image: docker.pkg.github.com/<ORG>/<REPO>/<PKG>:<TAG>
imagePullSecrets:
- name: dockerconfigjson-github-com
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3008 次 |
| 最近记录: |