k8s1.21-镜像准备
【前言】
- 需求:离线部署提前下载镜像
- 环境:在一台可上网的服务器上安装了kubeadm 1.21.0 的机器上完成下载
1. 更换阿里镜像源
【报错】
直接用kubeadm下载报错如下:
[root@k8s-1-21 ~]# kubeadm config images pull W0706 10:55:11.149871 6561 version.go:102] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get "https://dl.k8s.io/release/stable-1.txt": dial tcp 34.107.204.206:443: connect: connection timed out W0706 10:55:11.149926 6561 version.go:103] falling back to the local client version: v1.21.2 failed to pull image "k8s.gcr.io/kube-apiserver:v1.21.2": output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) , error: exit status 1 To see the stack trace of this error execute with --v=5 or higher
【分析】
国外的镜像下不下来也无所谓,反正我们初始化集群的时候可以指定镜像仓库。
所以我们此时也把镜像源的参数加上,下载阿里云的镜像。
【解决】
添加--image-repository registry.aliyuncs.com/google_containers
参数,指定镜像源
[root@k8s-1-21 ~]# kubeadm config images pull --image-repository registry.aliyuncs.com/google_containers W0706 10:58:05.269162 6878 version.go:102] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get "https://dl.k8s.io/release/stable-1.txt": dial tcp 34.107.204.206:443: connect: connection timed out W0706 10:58:05.269222 6878 version.go:103] falling back to the local client version: v1.21.2 [config/images] Pulled registry.aliyuncs.com/google_containers/kube-apiserver:v1.21.2 [config/images] Pulled registry.aliyuncs.com/google_containers/kube-controller-manager:v1.21.2 [config/images] Pulled registry.aliyuncs.com/google_containers/kube-scheduler:v1.21.2 [config/images] Pulled registry.aliyuncs.com/google_containers/kube-proxy:v1.21.2 [config/images] Pulled registry.aliyuncs.com/google_containers/pause:3.4.1 [config/images] Pulled registry.aliyuncs.com/google_containers/etcd:3.4.13-0 failed to pull image "registry.aliyuncs.com/google_containers/coredns:v1.8.0": output: Error response from daemon: manifest for registry.aliyuncs.com/google_containers/coredns:v1.8.0 not found: manifest unknown: manifest unknown , error: exit status 1 To see the stack trace of this error execute with --v=5 or higher
如上可见,除了coredns:v1.8.0 这个镜像没有其他镜像都成功下载了。
下边我们解决coredns:v1.8.0 这个镜像的问题。
2. coredns:v1.8.0 not found
阿里没有找到 coredns:v1.8.0这个镜像
我是去公网搜了一个,pull下来,改成registry.aliyuncs.com/google_containers/coredns:v1.8.0
,试了是可以用的。
[root@master-01 ~]# docker search coredns:v1.8.0 NAME DESCRIPTION STARS OFFICIAL AUTOMATED louwy001/coredns-coredns k8s.gcr.io/coredns/coredns:v1.8.0 1
开始想用阿里云的latest版本,然后吧tag改成1.8.0 ,试了一下一直启动不起来
[root@edge-master ~]# kubectl get pod -n kube-system NAME READY STATUS RESTARTS AGE coredns-59d64cd4d4-78cz5 0/1 Running 0 9m30s coredns-59d64cd4d4-x4t45 0/1 Running 0 9m57s
3. 离线部署镜像使用
提供两个方案
【方案一】
- 把刚才下载的镜像传到每台服务器
- init.yaml 文件修改为阿里云镜像仓库
imageRepository: registry.aliyuncs.com/google_containers
【方案二】
- 将刚才下载的镜像push到私有镜像仓库
- init.yaml 文件修改为私有镜像仓库
imageRepository: harbocto.xxx.com.cn/kubernetes
合集:
第二章 集群安装
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~