docker/kubernetes国内源/镜像源解决方式

2021-04-12 07:27

阅读:406

标签:git   sha   elastics   object   name   bbb   yun   kubectl   ssi   

大佬开发了一个小的脚本azk8spull,这个脚本可以自动根据镜像名称进行解析,转换为azure的mirror镜像源域名。并进行拉取。拉取完成后会自动进行tag重命名为原本的镜像名

脚本已经开源在 https://github.com/xuxinkun/littleTools#azk8spull 上。下面是示例:

[root@iZbp143t3oxhfc3ar7jey0Z ~]# yum install git
Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                                                                                               | 3.6 kB  00:00:00
epel                                                                                                                               | 5.3 kB  00:00:00
extras                                                                                                                             | 2.9 kB  00:00:00
updates                                                                                                                            | 2.9 kB  00:00:00
(1/3): epel/x86_64/updateinfo                                                                                                      | 1.0 MB  00:00:00
(2/3): epel/x86_64/primary_db                                                                                                      | 6.7 MB  00:00:00
(3/3): updates/7/x86_64/primary_db                                                                                                 | 6.7 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-21.el7_7 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-21.el7_7 for package: git-1.8.3.1-21.el7_7.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-21.el7_7.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-21.el7_7.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.3.1-21.el7_7.x86_64
--> Running transaction check
---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
---> Package perl-Git.noarch 0:1.8.3.1-21.el7_7 will be installed
---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                                  Arch                           Version                                    Repository                       Size
==========================================================================================================================================================
Installing:
 git                                      x86_64                         1.8.3.1-21.el7_7                           updates                         4.4 M
Installing for dependencies:
 perl-Error                               noarch                         1:0.17020-2.el7                            base                             32 k
 perl-Git                                 noarch                         1.8.3.1-21.el7_7                           updates                          55 k
 perl-TermReadKey                         x86_64                         2.30-20.el7                                base                             31 k

Transaction Summary
==========================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 4.5 M
Installed size: 22 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): perl-TermReadKey-2.30-20.el7.x86_64.rpm                                                                                     |  31 kB  00:00:00
(2/4): perl-Error-0.17020-2.el7.noarch.rpm                                                                                         |  32 kB  00:00:00
(3/4): perl-Git-1.8.3.1-21.el7_7.noarch.rpm                                                                                        |  55 kB  00:00:00
(4/4): git-1.8.3.1-21.el7_7.x86_64.rpm                                                                                             | 4.4 MB  00:00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                     5.0 MB/s | 4.5 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:perl-Error-0.17020-2.el7.noarch                                                                                                      1/4
  Installing : perl-TermReadKey-2.30-20.el7.x86_64                                                                                                    2/4
  Installing : perl-Git-1.8.3.1-21.el7_7.noarch                                                                                                       3/4
  Installing : git-1.8.3.1-21.el7_7.x86_64                                                                                                            4/4
  Verifying  : git-1.8.3.1-21.el7_7.x86_64                                                                                                            1/4
  Verifying  : 1:perl-Error-0.17020-2.el7.noarch                                                                                                      2/4
  Verifying  : perl-Git-1.8.3.1-21.el7_7.noarch                                                                                                       3/4
  Verifying  : perl-TermReadKey-2.30-20.el7.x86_64                                                                                                    4/4

Installed:
  git.x86_64 0:1.8.3.1-21.el7_7

Dependency Installed:
  perl-Error.noarch 1:0.17020-2.el7                perl-Git.noarch 0:1.8.3.1-21.el7_7                perl-TermReadKey.x86_64 0:2.30-20.el7

Complete!
[root@iZbp143t3oxhfc3ar7jey0Z ~]# git clone https://github.com/xuxinkun/littleTools
Cloning into ‘littleTools‘...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 48 (delta 0), reused 1 (delta 0), pack-reused 45
Unpacking objects: 100% (48/48), done.
[root@iZbp143t3oxhfc3ar7jey0Z ~]# ll
total 799316
-rw-r--r-- 1 root root        28 Feb 20 21:50 aaa.text
-rw------- 1 root root 500336640 Feb 21 22:15 elasticsearch.tar
drwxr-xr-x 4 root root      4096 Mar  3 13:57 littleTools
drwxr-xr-x 2 root root      4096 Feb 17 21:39 mysql-5.6.35-linux-glibc2.5-x86_64
-rw-r--r-- 1 root root 314581668 Feb 17 21:38 mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
drwxrwxr-x 5 1000 1000      4096 Feb 21 19:41 ngx_openresty-1.9.7.1
-rw-r--r-- 1 root root   3548444 Dec 25  2015 ngx_openresty-1.9.7.1.tar.gz
[root@iZbp143t3oxhfc3ar7jey0Z ~]# cd littleTools
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# chmod +x install.sh
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# ./install.sh
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# source /etc/profile
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# curl -Lo /usr/local/bin/azk8spull https://github.com/xuxinkun/littleTools/releases/download/v1.0.0/azk8spull && chmod +x /usr/local/bin/azk8spull
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   599  100   599    0     0    459      0  0:00:01  0:00:01 --:--:--   459
100  1721  100  1721    0     0    383      0  0:00:04  0:00:04 --:--:--   561
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]#  azk8spull quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.24.1
## azk8spull try to pull image from mirror quay.azk8s.cn/kubernetes-ingress-controller/nginx-ingress-controller:0.24.1.
Trying to pull repository quay.azk8s.cn/kubernetes-ingress-controller/nginx-ingress-controller ...
0.24.1: Pulling from quay.azk8s.cn/kubernetes-ingress-controller/nginx-ingress-controller
2b62f6d982a4: Pull complete
309c38216e9e: Pull complete
67357cb42bf0: Pull complete
6801e3761690: Pull complete
283784e0fc39: Pull complete
7640798c27e1: Pull complete
4adce86fa154: Pull complete
61901ee685f0: Pull complete
9e8e5a31c07d: Pull complete
a63dc2e51298: Pull complete
f8802b52271a: Pull complete
9e0acb4ae701: Pull complete
d3990828b952: Pull complete
Digest: sha256:76861d167e4e3db18f2672fd3435396aaa898ddf4d1128375d7c93b91c59f87f
Status: Downloaded newer image for quay.azk8s.cn/kubernetes-ingress-controller/nginx-ingress-controller:0.24.1
## azk8spull try to tag quay.azk8s.cn/kubernetes-ingress-controller/nginx-ingress-controller:0.24.1 to quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.24.1.
## azk8spull finish pulling.
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# azk8spull k8s.gcr.io/pause-amd64:3.1
## azk8spull try to pull image from mirror gcr.azk8s.cn/google_containers/pause-amd64:3.1.
Trying to pull repository gcr.azk8s.cn/google_containers/pause-amd64 ...
3.1: Pulling from gcr.azk8s.cn/google_containers/pause-amd64
67ddbfb20a22: Pull complete
Digest: sha256:59eec8837a4d942cc19a52b8c09ea75121acc38114a2c68b98983ce9356b8610
Status: Downloaded newer image for gcr.azk8s.cn/google_containers/pause-amd64:3.1
## azk8spull try to tag gcr.azk8s.cn/google_containers/pause-amd64:3.1 to k8s.gcr.io/pause-amd64:3.1.
## azk8spull finish pulling.
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# docker images
REPOSITORY                                                             TAG                 IMAGE ID            CREATED             SIZE
quay.azk8s.cn/kubernetes-ingress-controller/nginx-ingress-controller   0.24.1              98675eb54d0e        10 months ago       631 MB
quay.io/kubernetes-ingress-controller/nginx-ingress-controller         0.24.1              98675eb54d0e        10 months ago       631 MB
docker.io/elasticsearch                                                latest              5acf0e8da90b        17 months ago       486 MB
gcr.azk8s.cn/google_containers/pause-amd64                             3.1                 da86e6ba6ca1        2 years ago         742 kB
k8s.gcr.io/pause-amd64                                                 3.1                 da86e6ba6ca1        2 years ago         742 kB
docker.io/containerize/elastichd                                       latest              c2202f76db37        2 years ago         28.1 MB
docker.io/mobz/elasticsearch-head                                      5                   b19a5c98e43b        3 years ago         824 MB
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# azk8spull quay.io/coreos/flannel:v0.11.0-amd64
## azk8spull try to pull image from mirror quay.azk8s.cn/coreos/flannel:v0.11.0-amd64.
Trying to pull repository quay.azk8s.cn/coreos/flannel ...
v0.11.0-amd64: Pulling from quay.azk8s.cn/coreos/flannel
cd784148e348: Pull complete
04ac94e9255c: Pull complete
e10b013543eb: Pull complete
005e31e443b1: Pull complete
74f794f05817: Pull complete
Digest: sha256:7806805c93b20a168d0bbbd25c6a213f00ac58a511c47e8fa6409543528a204e
Status: Downloaded newer image for quay.azk8s.cn/coreos/flannel:v0.11.0-amd64
## azk8spull try to tag quay.azk8s.cn/coreos/flannel:v0.11.0-amd64 to quay.io/coreos/flannel:v0.11.0-amd64.
## azk8spull finish pulling.
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]# docker images
REPOSITORY                                                             TAG                 IMAGE ID            CREATED             SIZE
quay.io/kubernetes-ingress-controller/nginx-ingress-controller         0.24.1              98675eb54d0e        10 months ago       631 MB
quay.azk8s.cn/kubernetes-ingress-controller/nginx-ingress-controller   0.24.1              98675eb54d0e        10 months ago       631 MB
quay.azk8s.cn/coreos/flannel                                           v0.11.0-amd64       ff281650a721        13 months ago       52.6 MB
quay.io/coreos/flannel                                                 v0.11.0-amd64       ff281650a721        13 months ago       52.6 MB
docker.io/elasticsearch                                                latest              5acf0e8da90b        17 months ago       486 MB
gcr.azk8s.cn/google_containers/pause-amd64                             3.1                 da86e6ba6ca1        2 years ago         742 kB
k8s.gcr.io/pause-amd64                                                 3.1                 da86e6ba6ca1        2 years ago         742 kB
docker.io/containerize/elastichd                                       latest              c2202f76db37        2 years ago         28.1 MB
docker.io/mobz/elasticsearch-head                                      5                   b19a5c98e43b        3 years ago         824 MB
[root@iZbp143t3oxhfc3ar7jey0Z littleTools]#

kubeadm源

kubeadm直接使用阿里云的源即可。速度也比较快。

# Debian/Ubuntu
apt-get update && apt-get install -y apt-transport-https
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
 
# CentOS/RHEL/Fedora
cat  /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
setenforce 0
yum install -y kubelet kubeadm kubectl

 

docker/kubernetes国内源/镜像源解决方式

标签:git   sha   elastics   object   name   bbb   yun   kubectl   ssi   

原文地址:https://www.cnblogs.com/dalianpai/p/12402075.html


评论


亲,登录后才可以留言!