Gei*_*eis 3 kubernetes docker-registry kubernetes-secrets
我想访问多个远程注册表来提取图像。在 k8s文档中他们说:
(如果您需要访问多个注册表,您可以为每个注册表创建一个密钥。Kubelet 会将任何 imagePullSecret 合并到单个虚拟 .docker/config.json 中)
所以 POD 定义应该是这样的:
apiVersion: v1
kind: Pod
spec:
containers:
- name: ...
imagePullSecrets:
- name: secret1
- name: secret2
- ....
- name: secretN
Run Code Online (Sandbox Code Playgroud)
现在我不确定K8S如何为每张图像选择正确的秘密?所有秘密每次都会被一一验证吗?K8S如何处理失败的重试?如果特定数量的未经授权的重试可能会导致 k8sor docker 注册表中出现某种锁定状态?
/ 谢谢
您可以使用以下脚本在一个密钥中添加两个身份验证
#!/bin/bash
u1="user_1_here"
p1="password_1_here"
auth1=$(echo -n "$u1:$p1" | base64 -w0)
u2="user_2_here"
p2="password_2_here"
auth2=$(echo -n "$u2:$p2" | base64 -w0)
cat <<EOF > docker_config.json
{
"auths": {
"repo1_name_here": {
"auth": "$auth1"
},
"repo2_name_here": {
"auth": "$auth2"
}
}
}
EOF
base64 -w0 docker_config.json > docker_config_b64.json
cat <<EOF | kubectl apply -f -
apiVersion: v1
type: kubernetes.io/dockerconfigjson
kind: Secret
data:
.dockerconfigjson: $(cat docker_config_b64.json)
metadata:
name: specify_secret_name_here
namespace: specify_namespace_here
EOF
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2247 次 |
| 最近记录: |