Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

基于Travis CI 镜像k8s镜像的解决方案

NotificationsYou must be signed in to change notification settings

Mr-Linus/k8s-mirrors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

通过image-pull 镜像工具自动触发拉取官方 k8s 镜像并推送到阿里云容器镜像仓库

build

原理

利用image-pull 镜像工具自动化构建本项目客户端镜像,协助我们拉取 gcr.io 的镜像,打上 tag 并推送至阿里云,实现容器镜像的国内mirrors。本项目致力于搭建完整的 K8S 平台,如果需要其他额外镜像,您可以使用image-pull 镜像工具实现镜像拉取。

目前同步的k8s版本:V1.12.5 - V1.17.x(最新)

  • 2019.9.24 支持自动更新镜像
  • 2018.8.15 已同步 dashboard 镜像
  • 2018.9.1 已同步 ingress-nginx 镜像

国内拉取 gcr.io 镜像

  • 如果你的机器可以翻越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

需要注意的是,每个节点无论是工作节点还是master节点都需要拉取镜像!!

否则将会出现pod一直处于pending或者构建镜像的状态!!

下面可以做什么:

  • 拉取 CNI 镜像可选的集群网络方案:flannelcalico,这里以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

关于拉取 quay.io 镜像

假设需要拉取的镜像名写在文件/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

有任何问题欢迎issue!

img-source-from-https://github.com/docker/dockercraft

About

基于Travis CI 镜像k8s镜像的解决方案

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp