国内拉取google kubernetes镜像

常用镜像仓库

DockerHub镜像仓库:
https://hub.docker.com/

google镜像仓库:
https://gcr.io/google-containers/
https://gcr.io/kubernetes-helm/
https://gcr.io/google-containers/pause

quay.io镜像仓库:
https://quay.io/repository/

elastic镜像仓库:
https://www.docker.elastic.co/

RedHat镜像仓库
https://access.redhat.com/containers

阿里云镜像仓库:
https://cr.console.aliyun.com

华为云镜像仓库:
https://console.huaweicloud.com/swr

腾讯云镜像仓库:
https://console.cloud.tencent.com/tcr

常用镜像同步神器

阿里云image-syncer:https://github.com/AliyunContainerService/image-syncer

腾讯云image-transfer:https://github.com/tkestack/image-transfer

skopeo-sync:https://github.com/containers/skopeo/blob/master/docs/skopeo-sync.1.md

可结合公网CICD工具TravisCI、githubAction、gitlabCI等,将gcr.io镜像定期同步到个人dockerhub账号下或国内镜像仓库中。示例参考:https://github.com/willzhang/image-sync

国内镜像源

部分国外镜像仓库无法访问,但国内有对应镜像源,可以从以下镜像源拉取到本地然后重改tag即可:
阿里云镜像仓库

可以拉取k8s.gcr.io镜像

#示例
docker pull k8s.gcr.io/pause:3.2

#改为
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2


dockerhub镜像仓库

可以拉取k8s.gcr.io镜像

#示例
docker pull k8s.gcr.io/pause:3.1
docker pull k8s.gcr.io/kube-apiserver:v1.17.3

#改为
docker pull googlecontainersmirrors/pause:3.1
docker pull googlecontainersmirrors/kube-apiserver:v1.17.3


七牛云镜像仓库

可以拉取quay.io镜像

#示例
docker pull quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0

#改为
docker pull quay-mirror.qiniu.com/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0


dockerhub搜索镜像
很多国外镜像已经有热心网友传到了dockerhub,例如gcr.io/kubernetes-helm/tiller:v2.16.5这个镜像,直接搜索关键字,找到排序靠前的然后在dockerhub确认并拉取即可:

# docker search tiller
NAME                                    DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
jessestuart/tiller                      Nightly multi-architecture (amd64, arm64, ar  19                                      [OK]
sapcc/tiller                            Mirror of https://gcr.io/kubernetes-helm/til  9                                       
ist0ne/tiller                           https://gcr.io/kubernetes-helm/tiller           ....                                                                       


dockerhub镜像国内加速

阿里云镜像加速
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://uyah70su.mirror.aliyuncs.com"]
}
EOF


daocloud dockerhub镜像加速
https://www.daocloud.io/mirror

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io


华为云dockerhub镜像加速
https://console.huaweicloud.com/swr

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<- 'EOF'
{
    "registry-mirrors": ["https://7bafc985f90c43b887a96c2b846cf984.mirror.swr.myhuaweicloud.com"]
}
EOF


然后重新启动 Docker 服务:

sudo systemctl daemon-reload && sudo systemctl restart docker


验证加速器是否生效

$ docker info | grep Mirrors -A1
Registry Mirrors:
 https://uyah70su.mirror.aliyuncs.com/

#验证镜像拉取速度
$ time docker pull centos


直接拉取国外镜像

如果你已经在本地windows上使用番茄工具,默认可以通过它的1080端口来拉取镜像。
在安装docker的linux服务器执行以下操作,其中192.168.0.103是你本地windows能上网的网卡IP:

mkidr -p /etc/systemd/system/docker.service.d

cat > /etc/systemd/system/docker.service.d/http-proxy.conf  <<EOF
[Service]
Environment="HTTP_PROXY=http://192.168.0.103:1080"
EOF

systemctl daemon-reload && systemctl restart docker


注意还要在客户端里鼠标右键勾选允许其他设备连接。以上配置完成后即可直接拉取google镜像

# docker pull k8s.gcr.io/kube-apiserver:v1.16.1
v1.16.1: Pulling from kube-apiserver
39fafc05754f: Already exists 
010af2aa5529: Pull complete 
Digest: sha256:80feeaed6c6445ab0ea0c27153354c3cac19b8b028d9b14fc134f947e716e25e
Status: Downloaded newer image for k8s.gcr.io/kube-apiserver:v1.16.1
k8s.gcr.io/kube-apiserver:v1.16.1


创建个人仓库

我们也可以在dockerhub或阿里云创建个人仓库,把需要的最新版本镜像从google仓库push到个人仓库,一般有几下几种方法:

1.购买云服务器

购买1台能同时访问国外和国内网络的云服务器,例如阿里云或腾讯云香港轻量服务器。

或者使用google cloudshell:https://console.cloud.google.com/cloudshell
它类似一个永久免费的拥有5G存储空间的linux服务器,能够执行所有docker命令和bash命令,最重要的是它能够访问全球网络。

2.Github镜像构建功能
使用github的dockerfile构建功能,将镜像构建到国内仓库。
参考:https://blog.csdn.net/networken/article/details/85215714

查看gcloud容器镜像

登录到google cloudshell

查看某个项目下的镜像

gcloud container images list --project google-containers
gcloud container images list --project kubernetes-helm

gcr.io

查看某个仓库所有镜像

gcloud container images list --repository=gcr.io/google-containers


查看某个镜像所有tag

gcloud container images list-tags gcr.io/google-containers/metrics-server


k8s.gcr.io

gcloud container images list --repository=k8s.gcr.io/metrics-server
gcloud container images list-tags k8s.gcr.io/metrics-server/metrics-server

gcloud container images list-tags \
  k8s.gcr.io/metrics-server/metrics-server \
  --format="table(TAGS)" \
  --filter="tags:*" | grep -v TAGS


参考:
https://docs.docker.com/config/daemon/systemd/#httphttps-proxy
https://blog.csdn.net/nklinsirui/article/details/80581286
https://www.cnblogs.com/xuxinkun/p/11025020.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值