K8S使用阿里云镜像仓库
1. Node使用docker login阿里云的私有仓库,保证调度过来pod时可以及时拉取到镜像
docker login --username=xxx@hotmail.com registry.cn-hangzhou.aliyuncs.com
2. 需要在master上生成secret秘钥
kubectl create secret docker-registry alidockerregistryssecret --docker-server=registry.cn-hangzhou.aliyuncs.com --docker-username=xxx --docker-password=xxx --docker-email=xxxx@xxx.com
说明:
alidockerregistryssecret :指定秘钥的键名称,可自行定义
--docker-server :指定docker仓库的地址
--docker-username :指定docker仓库账号
--docker-password :指定docker仓库密码
--docker-email: 指定docker邮件地址(选填)
alidockerregistryssecret 只能在默认namespace下使用,其他要使用则在创建时指定namespace(-n xxx)
3.将ImagePullSecrets添加到default
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "alidockerregistryssecret"}]}'
4. deployment,并执行kubectl create -f alidocker.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: centos-test
labels:
app: centos-test
spec:
replicas: 2
selector:
matchLabels:
app: centos-test
template:
metadata:
labels:
app: centos-test
spec:
serviceAccountName: default
imagePullSecrets:
- name: alidockerregistryssecret
containers:
- name: centos-test
image: registry.cn-hangzhou.aliyuncs.com/mj_ns/centos7:jre-slim
imagePullPolicy: IfNotPresent
command: ["/bin/bash"]
args: ["-c", "while true; do echo 'Hello World'; sleep 10;done"]
ports:
- containerPort: 80
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· Qt个人项目总结 —— MySQL数据库查询与断言