- Notifications
You must be signed in to change notification settings - Fork4
Mr-Linus/k8s-mirrors
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
通过image-pull 镜像工具自动触发拉取官方 k8s 镜像并推送到阿里云容器镜像仓库
利用image-pull 镜像工具自动化构建本项目客户端镜像,协助我们拉取 gcr.io 的镜像,打上 tag 并推送至阿里云,实现容器镜像的国内mirrors
。本项目致力于搭建完整的 K8S 平台,如果需要其他额外镜像,您可以使用image-pull 镜像工具实现镜像拉取。
- 2019.9.24 支持自动更新镜像
- 2018.8.15 已同步 dashboard 镜像
- 2018.9.1 已同步 ingress-nginx 镜像
- 如果你的机器可以翻越GFW,请忽略本步骤,如果你的机器不能翻越GFW,请遵循如下流程:
- 方法1:设置 kubeadm 拉取仓库
创建文件:image.yaml
apiVersion:kubeadm.k8s.io/v1alpha3kind:ClusterConfigurationimageRepository:registry.cn-hangzhou.aliyuncs.com/image-mirror
拉取镜像(每个节点):
kubeadm config images pull --config image.yaml
- 方法2:运行容器拉取指定镜像
- 以版本V1.17.2为例
docker run --rm -it \ -v /var/run/docker.sock:/var/run/docker.sock \ registry.cn-hangzhou.aliyuncs.com/geekcloud/image-pull:k8s-v1.17.2
- 方法3:执行命令:
images=($(kubeadm config images list2>/dev/null| awk -F'/''{print $2}'))forimageNamein${images[@]};doecho"docker pull registry.cn-hangzhou.aliyuncs.com/image-mirror/${imageName}" docker pull registry.cn-hangzhou.aliyuncs.com/image-mirror/${imageName}echo"docker tag registry.cn-hangzhou.aliyuncs.com/image-mirror/${imageName} k8s.gcr.io/${imageName}" docker tag registry.cn-hangzhou.aliyuncs.com/image-mirror/${imageName} k8s.gcr.io/${imageName}echo"docker tag registry.cn-hangzhou.aliyuncs.com/image-mirror/${imageName} k8s.gcr.io/${imageName}" docker rmi registry.cn-hangzhou.aliyuncs.com/image-mirror/${imageName}done
- 拉取 CNI 镜像可选的集群网络方案:
flannel
或calico
,这里以flannel为例:
运行容器实现镜像拉取(可以GFW请忽略本步骤):
#获取镜像列表curl -s https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml| grep image| awk -F':''{ print $2 }'>$pwd/image-flannel.txt#拉取镜像docker run --rm -it \ -v$pwd/image-flannel.txt:/image-pull/image.txt \ -v /var/run/docker.sock:/var/run/docker.sock \ registry.cn-hangzhou.aliyuncs.com/geekcloud/image-pull:latest
假设需要拉取的镜像名写在文件/root/image.txt
中:
quay.io/coreos/flannel:v0.11.0quay.io/coreos/flannel:v0.12.0
运行容器实现镜像拉取:
docker run --rm -it \ -v /root/image.txt:/image-pull/image.txt \ -v /var/run/docker.sock:/var/run/docker.sock \ registry.cn-hangzhou.aliyuncs.com/geekcloud/image-pull:latest