Create Kubernetetes Mirror Service in Aliyun

Posted by toddg on Fri, 28 Feb 2020 17:51:21 +0100

Create Kubernetetes Mirror Service in Aliyun

Kubernetetes mirrors are not directly accessible at home, which makes installation time-consuming, error-prone and difficult to troubleshoot.You can grab it onto the Ali Cloud, then pull it locally in advance, and run the kubeadm installer much faster.

You can pull it locally by running the following script:

echo ""
echo "=========================================================="
echo "Pull Kubernetes 1.11.0 Images from aliyuncs.com ......"
echo "=========================================================="
echo ""

MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings

## Pull mirror
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver-amd64:v1.11.0
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager-amd64:v1.11.0
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler-amd64:v1.11.0
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy-amd64:v1.11.0
docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd-amd64:3.2.18
docker pull ${MY_REGISTRY}/k8s-gcr-io-pause-amd64:3.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.1.3

## Add Tag
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver-amd64:v1.11.0 k8s.gcr.io/kube-apiserver-amd64:v1.11.0
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler-amd64:v1.11.0 k8s.gcr.io/kube-scheduler-amd64:v1.11.0
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager-amd64:v1.11.0 k8s.gcr.io/kube-controller-manager-amd64:v1.11.0
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy-amd64:v1.11.0 k8s.gcr.io/kube-proxy-amd64:v1.11.0
docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd-amd64:3.2.18 k8s.gcr.io/etcd-amd64:3.2.18
docker tag ${MY_REGISTRY}/k8s-gcr-io-pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-coredns:1.1.3 k8s.gcr.io/coredns:1.1.3

echo ""
echo "=========================================================="
echo "Pull Kubernetes 1.11.0 Images FINISHED."
echo "into registry.cn-hangzhou.aliyuncs.com/openthings, "
echo "           by openthings@https://my.oschina.net/u/2306127."
echo "=========================================================="

echo ""

The k8s mirror script on aliyun is created as follows:


echo ""
echo "=========================================================="
echo "Push Kubernetes 1.11.0 Images into aliyuncs.com ......"
echo "=========================================================="
echo ""

echo "docker tag to openthings ..."

## Add Tag for registry.cn-hangzhou.aliyuncs.com/openthings

MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings

docker tag k8s.gcr.io/kube-apiserver-amd64:v1.11.0 ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver-amd64:v1.11.0 
docker tag k8s.gcr.io/kube-scheduler-amd64:v1.11.0 ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler-amd64:v1.11.0
docker tag k8s.gcr.io/kube-controller-manager-amd64:v1.11.0 ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager-amd64:v1.11.0 
docker tag k8s.gcr.io/kube-proxy-amd64:v1.11.0 ${MY_REGISTRY}/k8s-gcr-io-kube-proxy-amd64:v1.11.0 
docker tag k8s.gcr.io/etcd-amd64:3.2.18 ${MY_REGISTRY}/k8s-gcr-io-etcd-amd64:3.2.18 
docker tag k8s.gcr.io/pause-amd64:3.1 ${MY_REGISTRY}/k8s-gcr-io-pause-amd64:3.1 
docker tag k8s.gcr.io/coredns:1.1.3 ${MY_REGISTRY}/k8s-gcr-io-coredns:1.1.3 

echo ""
echo "=========================================================="
echo ""

## Push mirror
echo ""
echo "1.k8s-kube-apiserver-amd64"
docker push ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver-amd64:v1.11.0

echo ""
echo "2.k8s-kube-controller-manager-amd64"
docker push ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager-amd64:v1.11.0

echo ""
echo "3.k8s-kube-scheduler-amd64"
docker push ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler-amd64:v1.11.0

echo ""
echo "4.k8s-kube-proxy-amd64"
docker push ${MY_REGISTRY}/k8s-gcr-io-kube-proxy-amd64:v1.11.0

echo ""
echo "5.k8s-etcd-amd64"
docker push ${MY_REGISTRY}/k8s-gcr-io-etcd-amd64:3.2.18

echo ""
echo "6.k8s-pause-amd64"
docker push ${MY_REGISTRY}/k8s-gcr-io-pause-amd64:3.1

echo ""
echo "7.k8s-coredns"
docker push ${MY_REGISTRY}/k8s-gcr-io-coredns:1.1.3

echo ""
echo "=========================================================="
echo "Push Kubernetes 1.11.0 Images FINISHED."
echo "into registry.cn-hangzhou.aliyuncs.com/openthings, "
echo "           by openthings@https://my.oschina.net/u/2306127."
echo "=========================================================="

echo ""

The above script needs to be run on a machine that can access both gcr.io and the registry service of Ariyun. You can change it to your own container service (registry.cn-hangzhou.aliyuncs.com) of {East China 1} of Aliyun that I use here.

Topics: Docker Kubernetes