2018/2/7git
緣由:kubeadm init 時,須要下載一些鏡像,但國內網絡緣由,你們懂的,不容易下載,此時,只能去繞過它。
備註:官方在 1.5 收到阿里一位童鞋的 PR 來容許指定一個第三方的 registry 來解決上述問題,但由於時間所限,並未找到具體的操做方法。github
針對下述鏡像: 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、參考
一、阿里雲快速部署Kubernetes - VPC環境
https://yq.aliyun.com/articles/66474
二、support customize repository prefix of image through environment KUBE… #35948
https://github.com/kubernetes/kubernetes/pull/35948
三、Using custom images
https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/#custom-imagesdocker