博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kubernetes国内镜像拉取
阅读量:4963 次
发布时间:2019-06-12

本文共 7902 字,大约阅读时间需要 26 分钟。

因国内访问不到goole服务器,只能拉取国内的镜像,这里以阿里云为例。

安装minikube时报failed to pull image "k8s.gcr.io/kube-apiserver:v1.13.4"。

原理:先拉取阿里镜像,再改名

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.2.24
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.2.24 k8s.gcr.io/etcd:3.2.24

1.准备脚本

先设置k8s镜像源

[root@localhost yum.repos.d]# cat kubernetes.repo[kubernetes]name=Kubernetesbaseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=0repo_gpgcheck=0gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg        http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg[root@localhost yum.repos.d]#

yum install -y kubelet-1.14.0 kubeadm-1.14.0 kubectl-1.14.0

后查看版本依赖

[root@localhost yum.repos.d]# kubeadm config images listI0401 11:37:19.728564   13794 version.go:96] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get https://storage.googleapis.com/kubernetes-release/release/stable-1.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)I0401 11:37:19.728628   13794 version.go:97] falling back to the local client version: v1.14.0k8s.gcr.io/kube-apiserver:v1.14.0k8s.gcr.io/kube-controller-manager:v1.14.0k8s.gcr.io/kube-scheduler:v1.14.0k8s.gcr.io/kube-proxy:v1.14.0k8s.gcr.io/pause:3.1k8s.gcr.io/etcd:3.3.10k8s.gcr.io/coredns:1.3.1[root@localhost yum.repos.d]#

 

[root@localhost bin]# vi pullK8s.sh #!/bin/bashKUBE_VERSION=v1.14.0KUBE_PAUSE_VERSION=3.1ETCD_VERSION=3.3.10DNS_VERSION=1.3.1username=registry.cn-hangzhou.aliyuncs.com/google_containersimages=(kube-proxy-amd64:${KUBE_VERSION}kube-scheduler-amd64:${KUBE_VERSION}kube-controller-manager-amd64:${KUBE_VERSION}kube-apiserver-amd64:${KUBE_VERSION}pause:${KUBE_PAUSE_VERSION}etcd-amd64:${ETCD_VERSION}coredns:${DNS_VERSION}    )for image in ${images[@]}do    new_image=`echo $image|sed 's/-amd64//g'` ##此处需删除“-amd64”,否则kuadm还是无法识别本地镜像    docker pull ${username}/${image}    docker tag ${username}/${image} k8s.gcr.io/${
new_image} #docker tag ${username}/${image} gcr.io/google_containers/${
image} docker rmi ${username}/${image} done

2.执行脚本

[root@localhost bin]# sh pullK8s.sh Trying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64 ... v1.13.4: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd6473e3e9d78c61: Already exists 0c440f353724: Pull complete 17ae2caf8e8d: Pull complete Digest: sha256:f1623e06b9b4685ae8cf4c57ad6180a16e5e90c6ddefe8b7da9b048d64a7def2Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64@sha256:f1623e06b9b4685ae8cf4c57ad6180a16e5e90c6ddefe8b7da9b048d64a7def2Trying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64 ... v1.13.4: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd6473e3e9d78c61: Already exists 1a875e158006: Pull complete Digest: sha256:c25486d95e850628afa11ae814235c70deb6e370c38970abf2e1809f67e94992Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64@sha256:c25486d95e850628afa11ae814235c70deb6e370c38970abf2e1809f67e94992Trying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64 ... v1.13.4: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd6473e3e9d78c61: Already exists 39e16f0f87fa: Pull complete Digest: sha256:6d8b8cd8fac8ddc9e67e4e208df2217b9d34a9294c4ab2be61adcbe2187bd1baStatus: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64@sha256:6d8b8cd8fac8ddc9e67e4e208df2217b9d34a9294c4ab2be61adcbe2187bd1baTrying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64 ... v1.13.4: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd6473e3e9d78c61: Already exists 758f1e738c78: Pull complete Digest: sha256:1a263e07cd22ef294b95f8bed4e29e92e281d580803c44a9741037f1825fbf5aStatus: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64:v1.13.4Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64@sha256:1a263e07cd22ef294b95f8bed4e29e92e281d580803c44a9741037f1825fbf5aTrying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/pause ... 3.1: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/pausecf9202429979: Pull complete Digest: sha256:759c3f0f6493093a9043cc813092290af69029699ade0e3dbe024e968fcb7ccaStatus: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/pause@sha256:759c3f0f6493093a9043cc813092290af69029699ade0e3dbe024e968fcb7ccaTrying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64 ... 3.2.18: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64032c9e83eacf: Pull complete 7b1383c20253: Pull complete b6d57b1fcbdf: Pull complete Digest: sha256:aee95913eeb1d4ab77d8017fd3331cbc73531227adb27918552d314c30236184Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64:3.2.18Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64:3.2.18Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64@sha256:aee95913eeb1d4ab77d8017fd3331cbc73531227adb27918552d314c30236184Trying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/coredns ... 1.1.3: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/coredns88286f41530e: Pull complete 9e8fb813cddc: Pull complete 3ac8c130be3b: Pull complete Digest: sha256:d929e48a87979279307111fd28a52272d3fac0ed1dc8f2f53a9489be45e5f2ebStatus: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.1.3Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.1.3Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/coredns@sha256:d929e48a87979279307111fd28a52272d3fac0ed1dc8f2f53a9489be45e5f2eb

3.查看镜像

[root@localhost shell]# docker imagesREPOSITORY                           TAG                 IMAGE ID            CREATED             SIZEk8s.gcr.io/kube-proxy                v1.14.0             5cd54e388aba        6 days ago          82.1 MBk8s.gcr.io/kube-scheduler            v1.14.0             00638a24688b        6 days ago          81.6 MBk8s.gcr.io/kube-controller-manager   v1.14.0             b95b1efa0436        6 days ago          158 MBk8s.gcr.io/kube-apiserver            v1.14.0             ecf910f40d6e        6 days ago          210 MBk8s.gcr.io/coredns                   1.3.1               eb516548c180        2 months ago        40.3 MBk8s.gcr.io/etcd                      3.3.10              2c4adeb21b4f        4 months ago        258 MBk8s.gcr.io/pause                     3.1                 da86e6ba6ca1        15 months ago       742 kB[root@localhost shell]#

 

转载于:https://www.cnblogs.com/pu20065226/p/10612607.html

你可能感兴趣的文章
[补档]happiness
查看>>
封装计算方法实现面向对象计算器。
查看>>
Python入门教程 超详细1小时学会Python
查看>>
JS对象创建常用方式及原理分析
查看>>
定时压缩日志文件并发送到邮箱
查看>>
postgresql 一些操作
查看>>
《深入浅出深度学习:原理剖析与python实践》第八章前馈神经网络(笔记)
查看>>
linux shell中读写操作mysql数据库
查看>>
算法-翻转句子中单词的顺序
查看>>
关于测绘类软件的学习心得
查看>>
二叉搜索树的后序遍历序列 (java)
查看>>
Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy
查看>>
微信小说域名被封-366tool在线解答微信屏蔽小说网页停止访问的解决方案
查看>>
.NET Core项目与传统vs项目的细微不同
查看>>
TouchDevelop [Mobile App]
查看>>
BZOJ 1861: [Zjoi2006]Book 书架
查看>>
矩阵乘法&&dp加速矩阵的思路(E. Wet Shark and Blocks)
查看>>
Netflix开源的Spring Cloud主机级性能监控框架--Vector
查看>>
HTML5 在泛在电力物联网的 10 大业务领域 2/3D 可视化应用
查看>>
共享Visio和project的下载链接
查看>>