最近在使用kubeadm時,被各類鏈接不上搞到崩潰。費了不少力氣,基本都解決了。這裏統一整理了國內的一些鏡像源,apt源,kubeadm源等,以便查閱。html
Azure China提供了目前用過的質量最好的鏡像源。不管是速度仍是覆蓋範圍。並且都支持匿名拉取,也就是不須要登陸。這點特別友好。node
這裏,我開發了一個小的腳本azk8spull,這個腳本能夠自動根據鏡像名稱進行解析,轉換爲azure的mirror鏡像源域名。並進行拉取。拉取完成後會自動進行tag重命名爲本來的鏡像名。該腳本已經開源在 https://github.com/xuxinkun/littleTools#azk8spull 上。如下是樣例。nginx
[root@node-64-216 ~]# 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. 0.24.1: Pulling from kubernetes-ingress-controller/nginx-ingress-controller Digest: sha256:76861d167e4e3db18f2672fd3435396aaa898ddf4d1128375d7c93b91c59f87f Status: Image is up to date 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@node-64-216 ~]# azk8spull k8s.gcr.io/pause-amd64:3.1 ## azk8spull try to pull image from mirror gcr.azk8s.cn/google_containers/pause-amd64:3.1. 3.1: Pulling from google_containers/pause-amd64 Digest: sha256:59eec8837a4d942cc19a52b8c09ea75121acc38114a2c68b98983ce9356b8610 Status: Image is up to date 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.
azk8s.cn支持的鏡像轉換以下列表。git
global | proxy in China | format | example |
---|---|---|---|
dockerhub (docker.io) | dockerhub.azk8s.cn | dockerhub.azk8s.cn/<repo-name>/<image-name>:<version> |
dockerhub.azk8s.cn/microsoft/azure-cli:2.0.61 dockerhub.azk8s.cn/library/nginx:1.15 |
gcr.io | gcr.azk8s.cn | gcr.azk8s.cn/<repo-name>/<image-name>:<version> |
gcr.azk8s.cn/google_containers/hyperkube-amd64:v1.13.5 |
quay.io | quay.azk8s.cn | quay.azk8s.cn/<repo-name>/<image-name>:<version> |
quay.azk8s.cn/deis/go-dev:v1.10.0 |
Note:
k8s.gcr.io
would redirect togcr.io/google-containers
, following image urls are identical:github
k8s.gcr.io/pause-amd64:3.1 gcr.io/google_containers/pause-amd64:3.1
debian的apt的國內源更換爲163的源,能夠顯著加速。docker
mv /etc/apt/sources.list /etc/apt/sources.list.bak # 換下源 echo "deb http://mirrors.163.com/debian/ stretch main non-free contrib deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib deb-src http://mirrors.163.com/debian/ stretch main non-free contrib deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" > /etc/apt/sources.list
kubeadm直接使用阿里雲的源便可。速度也比較快。curl
# 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 <<EOF >/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 <<EOF > /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