背景
笔者的客户交付是镜像交付,集群访问需要设置对应的 secret。
生成 docker 账密base64
echo -n 'your-docker-username:your-docker-password' | base64
创建 docker-config.json 文件
{
"auths": {
"[https://index.docker.io/v1/](https://index.docker.io/v1/)": {
"auth": "your-auth-base64-encoded"
}
}
}
创建 Secret
kubectl create secret generic <secret-name> --from-file=.dockerconfigjson=<path/to/docker-config.json> --type=kubernetes.io/dockerconfigjson -n <target_namespace>
解密base64
有时候我们要查看账密。
echo <BASE64_ENCODED_DATA> | base64 -d | jq .
至于 jq 这个命令,直接 Homebrew 安装即可。