创建阿里云镜像仓库imagePullSecrets
一、通过docker config.json
1.docker登录仓库,根据提示
1 2 3 4 5 6 | [root@ks-node05 ~]# docker login --username=mq-ops2@1910650714221478 registry-vpc.cn-hangzhou.aliyuncs.com #因为是阿里云ECS,所以用了registry-vpc Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https: //docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded |
登录过程会创建或更新保存有授权令牌的 config.json
文件
1 2 3 4 5 6 7 8 9 10 11 | [root@ks-node05 ~]# ll .docker/ total 4 -rw------- 1 root root 157 Nov 9 11:48 config.json [root@ks-node05 ~]# cat .docker/config.json { "auths" : { "registry-vpc.cn-hangzhou.aliyuncs.com" : { "auth" : "bXEtb3BzMkAxOTEwNjUwNzExxxxxxxxTZWQ0dGS0hPMEdrM3BlN3VneUkzRFh1SmRyS0hU" } } } |
2.通过config.json
创建secret
1 2 3 4 5 | [root@ks-node05 ~]# kubectl create secret generic aliyuncs-registry-key -- from -file=.dockerconfigjson=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson -- namespace =mk1-uat secret/aliyuncs-registry-key created [root@ks-node05 ~]# kubectl get secret -n mk1-uat NAME TYPE DATA AGE aliyuncs-registry-key kubernetes.io/dockerconfigjson 1 30s |
3.YAML引用
1 | 在pods的spec.imagePullSecrets下引用即可 |
二、通过命令行直接创建
1 2 3 4 5 6 | # aliyuncs-registry-key2 secret 名称,自定义 kubectl -- namespace =mk1-uat create secret docker-registry aliyuncs-registry-key2 \ > --docker-server=registry-vpc.cn-hangzhou.aliyuncs.com \ > --docker-username=mq-ops2@1910650714221478 \ > --docker-password=${registry_passwd} \ > --docker-email=xxxx@qq.com |
"一劳永逸" 的话,有是有的,而 "一劳永逸" 的事却极少
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
2018-11-09 k8s学习笔记之八:存储卷
2017-11-09 安装配置Glusterfs
2017-11-09 ELK+zookeeper+kafka+rsyslog集群搭建