https://blog.csdn.net/m0_37814112/article/details/115863265
1、查看各版本镜像列表
下载kubeadm:链接
kubeadm config images list --kubernetes-version=v1.19.9
- 可以将docker官方地址
<font style="color:rgb(248, 248, 242);background-color:rgb(40, 42, 54);">k8s.gcr.io</font>修改为阿里云地址<font style="color:rgb(248, 248, 242);background-color:rgb(40, 42, 54);">registry.cn-hangzhou.aliyuncs.com/google_containers</font>
kubeadm config images list --kubernetes-version=v1.19.9 > k8s-images.listsed -i 's/k8s.gcr.io/registry.cn-hangzhou.aliyuncs.com\/google_containers/g' k8s-images.listvim k8s-images.list##k8s-images-1.19.9registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.19.9registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.19.9registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.19.9registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.19.9registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.13-0registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.7.0
- 添加几个镜像
- registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6.9
- 下载镜像脚本地址:链接
# 导出镜像./offline-installation-tool.sh -s -l k8s-images.list -d ./kubesphere-images# 导入镜像到私有仓库./offline-installation-tool.sh -l k8s-images.list -d ./kubesphere-images -r dockerhub.kubekey.local
vim push_image.sh#!/bin/bashold_url=registry.cn-hangzhou.aliyuncs.com/google_containersnew_url=dockerhub.kubekey.localnamespaceOverride=k8simages=(kube-apiserver:v1.19.9kube-controller-manager:v1.19.9kube-scheduler:v1.19.9kube-proxy:v1.19.9pause:3.2etcd:3.4.13-0coredns:1.7.0)for imagename in ${images[@]} ; dodocker tag ${old_url}/${imagename} ${new_url}/${namespaceOverride}/${imagename}docker push ${new_url}/${namespaceOverride}/${imagename}done
- 批量创建项目错误

[root@VM-0-12-centos apps]# yum install dos2unix[root@VM-0-12-centos apps]# dos2unix m_api.sh
2、使用脚本下载
1. 方法一
vim get_images.sh#!/bin/bashset -eKUBE_VERSION=v1.17.4KUBE_PAUSE_VERSION=3.1ETCD_VERSION=3.4.3-0CORE_DNS_VERSION=1.6.5GCR_URL=k8s.gcr.ioALIYUN_URL=registry.cn-hangzhou.aliyuncs.com/google_containersimages=(kube-proxy:${KUBE_VERSION}kube-scheduler:${KUBE_VERSION}kube-controller-manager:${KUBE_VERSION}kube-apiserver:${KUBE_VERSION}pause:${KUBE_PAUSE_VERSION}etcd:${ETCD_VERSION}coredns:${CORE_DNS_VERSION})for imageName in ${images[@]} ; dodocker pull $ALIYUN_URL/$imageNamedocker tag $ALIYUN_URL/$imageName $GCR_URL/$imageNamedocker rmi $ALIYUN_URL/$imageNamedone
2. 方法二
vim get_image.sh#!/bin/bashurl=registry.cn-hangzhou.aliyuncs.com/google_containersversion=v1.19.9images=(`kubeadm config images list --kubernetes-version=$version|awk -F '/' '{print $2}'`)for imagename in ${images[@]} ; dodocker pull $url/$imagenamedocker tag $url/$imagename k8s.gcr.io/$imagenamedocker rmi -f $url/$imagenamedone
说明:这里采用脚本的方式下载阿里云kubernetes核心镜像,然后修改tag,这样yaml文件的镜像名称就可以不用修改了。
