1. 程式人生 > >使用kubeadm部署k8s集群00-緩存gcr.io鏡像

使用kubeadm部署k8s集群00-緩存gcr.io鏡像

命名空間 sin sid ont -m images env reference sched

使用kubeadm部署k8s集群00-緩存gcr.io鏡像

2018/2/7

原因:kubeadm init 時,需要下載一些鏡像,但國內網絡原因,大家懂的,不容易下載,此時,只能去繞過它。
備註:官方在 1.5 收到阿裏一位童鞋的 PR 來允許指定一個第三方的 registry 來解決上述問題,但因為時間所限,並未找到具體的操作方法。

【在國外節點上操作】

  • 鏡像來源
針對下述鏡像:

gcr.io/google_containers/kube-apiserver-amd64:v1.9.0
gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0
gcr.io/google_containers/kube-scheduler-amd64:v1.9.0
gcr.io/google_containers/kube-proxy-amd64:v1.9.0
gcr.io/google_containers/etcd-amd64:3.1.10
gcr.io/google_containers/pause-amd64:3.0
gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7
gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7
##### 先 pull 下來

docker pull gcr.io/google_containers/kube-apiserver-amd64:v1.9.0
docker pull gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0
docker pull gcr.io/google_containers/kube-scheduler-amd64:v1.9.0
docker pull gcr.io/google_containers/kube-proxy-amd64:v1.9.0
docker pull gcr.io/google_containers/etcd-amd64:3.1.10
docker pull gcr.io/google_containers/pause-amd64:3.0
docker pull gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7
docker pull gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7
docker pull gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7

##### 修改 tag 為新的倉庫/命名空間:

docker tag gcr.io/google_containers/kube-apiserver-amd64:v1.9.0 opera443399/kube-apiserver-amd64:v1.9.0
docker tag gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0 opera443399/kube-controller-manager-amd64:v1.9.0
docker tag gcr.io/google_containers/kube-scheduler-amd64:v1.9.0 opera443399/kube-scheduler-amd64:v1.9.0
docker tag gcr.io/google_containers/kube-proxy-amd64:v1.9.0 opera443399/kube-proxy-amd64:v1.9.0
docker tag gcr.io/google_containers/etcd-amd64:3.1.10 opera443399/etcd-amd64:3.1.10
docker tag gcr.io/google_containers/pause-amd64:3.0 opera443399/pause-amd64:3.0
docker tag gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7 opera443399/k8s-dns-sidecar-amd64:1.14.7
docker tag gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7 opera443399/k8s-dns-kube-dns-amd64:1.14.7
docker tag gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7 opera443399/k8s-dns-dnsmasq-nanny-amd64:1.14.7

##### 再 push 到新的倉庫/命名空間中:

docker push opera443399/kube-apiserver-amd64:v1.9.0
docker push opera443399/kube-controller-manager-amd64:v1.9.0
docker push opera443399/kube-scheduler-amd64:v1.9.0
docker push opera443399/kube-proxy-amd64:v1.9.0
docker push opera443399/etcd-amd64:3.1.10
docker push opera443399/pause-amd64:3.0
docker push opera443399/k8s-dns-sidecar-amd64:1.14.7
docker push opera443399/k8s-dns-kube-dns-amd64:1.14.7
docker push opera443399/k8s-dns-dnsmasq-nanny-amd64:1.14.7

##### 在目標機器上 pull 下來:

docker pull opera443399/kube-apiserver-amd64:v1.9.0
docker pull opera443399/kube-controller-manager-amd64:v1.9.0
docker pull opera443399/kube-scheduler-amd64:v1.9.0
docker pull opera443399/kube-proxy-amd64:v1.9.0
docker pull opera443399/etcd-amd64:3.1.10
docker pull opera443399/pause-amd64:3.0
docker pull opera443399/k8s-dns-sidecar-amd64:1.14.7
docker pull opera443399/k8s-dns-kube-dns-amd64:1.14.7
docker pull opera443399/k8s-dns-dnsmasq-nanny-amd64:1.14.7

##### 還原 tag 到目標鏡像:
docker tag opera443399/kube-apiserver-amd64:v1.9.0 gcr.io/google_containers/kube-apiserver-amd64:v1.9.0
docker tag opera443399/kube-controller-manager-amd64:v1.9.0 gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0
docker tag opera443399/kube-scheduler-amd64:v1.9.0 gcr.io/google_containers/kube-scheduler-amd64:v1.9.0
docker tag opera443399/kube-proxy-amd64:v1.9.0 gcr.io/google_containers/kube-proxy-amd64:v1.9.0
docker tag opera443399/etcd-amd64:3.1.10 gcr.io/google_containers/etcd-amd64:3.1.10
docker tag opera443399/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
docker tag opera443399/k8s-dns-sidecar-amd64:1.14.7 gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7
docker tag opera443399/k8s-dns-kube-dns-amd64:1.14.7 gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7
docker tag opera443399/k8s-dns-dnsmasq-nanny-amd64:1.14.7 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7

##### 清理中轉用到的鏡像 tag :
docker rmi $(docker images |grep opera443399 |awk ‘{print $1":"$2}‘)

ZYXW、參考
1、阿裏雲快速部署Kubernetes - VPC環境
https://yq.aliyun.com/articles/66474
2、support customize repository prefix of image through environment KUBE… #35948
https://github.com/kubernetes/kubernetes/pull/35948
3、Using custom images
https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/#custom-images

使用kubeadm部署k8s集群00-緩存gcr.io鏡像