kubernetes国内镜像拉取

因国内访问不到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.准备脚本

[root@localhost bin]# vi pullK8s.sh 

#!/bin/bash
KUBE_VERSION=v1.13.4
KUBE_PAUSE_VERSION=3.1
ETCD_VERSION=3.2.18
DNS_VERSION=1.1.3
username=registry.cn-hangzhou.aliyuncs.com/google_containers

images=(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
    docker pull ${username}/${image}
    docker tag ${username}/${image} k8s.gcr.io/${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-amd64
73e3e9d78c61: Already exists
0c440f353724: Pull complete
17ae2caf8e8d: Pull complete
Digest: sha256:f1623e06b9b4685ae8cf4c57ad6180a16e5e90c6ddefe8b7da9b048d64a7def2
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64@sha256:f1623e06b9b4685ae8cf4c57ad6180a16e5e90c6ddefe8b7da9b048d64a7def2
Trying 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-amd64
73e3e9d78c61: Already exists
1a875e158006: Pull complete
Digest: sha256:c25486d95e850628afa11ae814235c70deb6e370c38970abf2e1809f67e94992
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler-amd64@sha256:c25486d95e850628afa11ae814235c70deb6e370c38970abf2e1809f67e94992
Trying 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-amd64
73e3e9d78c61: Already exists
39e16f0f87fa: Pull complete
Digest: sha256:6d8b8cd8fac8ddc9e67e4e208df2217b9d34a9294c4ab2be61adcbe2187bd1ba
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager-amd64@sha256:6d8b8cd8fac8ddc9e67e4e208df2217b9d34a9294c4ab2be61adcbe2187bd1ba
Trying 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-amd64
73e3e9d78c61: Already exists
758f1e738c78: Pull complete
Digest: sha256:1a263e07cd22ef294b95f8bed4e29e92e281d580803c44a9741037f1825fbf5a
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64:v1.13.4
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64@sha256:1a263e07cd22ef294b95f8bed4e29e92e281d580803c44a9741037f1825fbf5a
Trying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/pause ...
3.1: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/pause
cf9202429979: Pull complete
Digest: sha256:759c3f0f6493093a9043cc813092290af69029699ade0e3dbe024e968fcb7cca
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/pause@sha256:759c3f0f6493093a9043cc813092290af69029699ade0e3dbe024e968fcb7cca
Trying 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-amd64
032c9e83eacf: Pull complete
7b1383c20253: Pull complete
b6d57b1fcbdf: Pull complete
Digest: sha256:aee95913eeb1d4ab77d8017fd3331cbc73531227adb27918552d314c30236184
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64:3.2.18
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64:3.2.18
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/etcd-amd64@sha256:aee95913eeb1d4ab77d8017fd3331cbc73531227adb27918552d314c30236184
Trying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/coredns ...
1.1.3: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/coredns
88286f41530e: Pull complete
9e8fb813cddc: Pull complete
3ac8c130be3b: Pull complete
Digest: sha256:d929e48a87979279307111fd28a52272d3fac0ed1dc8f2f53a9489be45e5f2eb
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.1.3
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.1.3
Untagged: registry.cn-hangzhou.aliyuncs.com/google_containers/coredns@sha256:d929e48a87979279307111fd28a52272d3fac0ed1dc8f2f53a9489be45e5f2eb

3.查看镜像

[root@localhost bin]# pwd
/usr/local/bin
[root@localhost bin]# docker images
REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
k8s.gcr.io/kube-proxy-amd64                v1.13.4             fadcc5d2b066        3 weeks ago         80.3 MB
k8s.gcr.io/kube-scheduler-amd64            v1.13.4             dd862b749309        3 weeks ago         79.6 MB
k8s.gcr.io/kube-controller-manager-amd64   v1.13.4             40a817357014        3 weeks ago         146 MB
k8s.gcr.io/kube-apiserver-amd64            v1.13.4             fc3801f0fc54        3 weeks ago         181 MB
k8s.gcr.io/coredns                         1.1.3               b3b94275d97c        10 months ago       45.6 MB
k8s.gcr.io/etcd-amd64                      3.2.18              b8df3b177be2        11 months ago       219 MB
k8s.gcr.io/pause                           3.1                 da86e6ba6ca1        15 months ago       742 kB
[root@localhost bin]# 

原文地址:https://www.cnblogs.com/pu20065226/p/10612607.html

时间: 2024-10-30 05:34:11

kubernetes国内镜像拉取的相关文章

K8s之Pod资源管理及创建Harbor私有镜像仓库(含镜像拉取操作,中途含排错)

pod是k8s管理的最小单元 pod中有多个容器,现实生产环境中只有一个容器 特点: 1.最小部署单元2.一组容器的集合3.一个Pod中的容器共享网络命令空间4.Pod是短暂的 Pod容器分类: 1:infrastructure container 基础容器(透明的过程,用户无感知) 维护整个Pod网络空间 node节点操作 `查看容器的网络` [[email protected] ~]# cat /opt/kubernetes/cfg/kubelet KUBELET_OPTS="--logto

yaml文件中镜像拉取策略

yaml文件中镜像拉取策略解释: containers: - name: coredns image: coredns/coredns:1.2.0 imagePullPolicy: IfNotPresent IfNotPresent :如果本地存在镜像就优先使用本地镜像. Never:直接不再去拉取镜像了,使用本地的:如果本地不存在就报异常了. Always 如果你yaml配置文件中没有定义那就是使用默认的 原文地址:https://www.cnblogs.com/effortsing/p/10

K8s 从懵圈到熟练 – 镜像拉取这件小事

作者 | 声东 阿里云售后技术专家 导读:相比 K8s 集群的其他功能,私有镜像的自动拉取,看起来可能是比较简单的.而镜像拉取失败,大多数情况下都和权限有关.所以,在处理相关问题的时候,我们往往会轻松的说:这问题很简单,肯定是权限问题.但实际的情况是,我们经常为一个问题,花了多个人的时间却找不到原因.这主要还是我们对镜像拉取,特别是私有镜像自动拉取的原理理解不深.这篇文章,作者将带领大家讨论下相关原理. 顺序上来说,私有镜像自动拉取会首先通过阿里云 Acr credential helper 组

Pod镜像拉取策略imagePullPolicy

默认值是IfNotPresent Always 总是拉取: 首先获取仓库镜像信息, 如果仓库中的镜像与本地不同,那么仓库中的镜像会被拉取并覆盖本地. 如果仓库中的镜像与本地一致,那么不会拉取镜像. 如果仓库不可用,那么pod运行失败. IfNotPresent 优先使用本地: 如果本地存在镜像,则使用本地的, 不管仓库是否可用. 不管仓库中镜像与本地是否一致. Never 只使用本地镜像,如果本地不存在,则pod运行失败 原文地址:https://www.cnblogs.com/orchidzj

docker镜像拉取、运行、删除

1.拉去hello-world镜像并运行 docker pull hello-world 拉取hello-world镜像Using default tag: latestlatest: Pulling from library/hello-world1b930d010525: Pull complete Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064Status: Downloaded

[Kubernetes] 国内获取 Kubernetes 镜像的方法

https://blog.csdn.net/shida_csdn/article/details/78480241一. 背景介绍 众所周知,由于国内网络原因,在搭建 Kubernetes 环境时,经常遇到必须的镜像找不到的情况. 到 DockerHub 捡垃圾毕竟不是个好办法,本文就教大家在 DockerHub 搭建自己的镜像仓库. 要求:有 GitHub 账号,有 DockerHub 账号,没有请注册. 二. 基本步骤 2.1 登陆 GitHub,创建代码仓库,比如:googlecontain

Docker Hub.拉取镜像

注:此记录谨基于默认在搭建好的docker环境下进行!   拉取镜像很假单,只需要一个“docker pull 镜像名“的命令即可.当然,前提是我们已经在一个已经搭建好的docker环境下.但是,如何将拉取到主机的镜像下载到本地电脑呢.请看如下记录: 假设我们要拉取的镜像是一个note基础镜像,那么我们执行的命令首先是:docker pull note .当镜像下载成功,我们需要检查一下,该镜像是否已经存在主机了.可以执行:docker images 查看镜像是否存在,如果没错的话,应该是有 n

docker 更换国内镜像仓库

问题:使用docker时报错"net/http: TLS handshake timeout"的解决方案docker默认镜像拉取地址为国外仓库下载速度较慢,则会报错"net/http: TLS handshake timeout".此时,只需要将拉取地址改为国内镜像仓库即可.标准格式为:$ docker pull registry.docker-cn.com/myname/myrepo:mytag例:$ docker pull registry.docker-cn.

使用Harbor配置Kubernetes私有镜像仓库

Harbor使用了基于角色的访问控制策略,当从Harbor中拉去镜像的时候,首先要进行身份认证,认证通过后才可以拉取镜像.在命令行模式下,需要先执行docker login,登陆成功后,才可以docker pull. 通常情况下,在私有云环境中使用kubernetes时,我们要从docker registry拉取镜像的时候,都会给docker daemo配置–insecure-registry属性来告诉docker daemo我们所使用的docker registry是可信的,这样才能从私有的d