本文共 4325 字,大约阅读时间需要 14 分钟。
2018/2/7
原因:kubeadm init 时,需要下载一些镜像,但国内网络原因,大家懂的,不容易下载,此时,只能去绕过它。
备注:官方在 1.5 收到阿里一位童鞋的 PR 来允许指定一个第三方的 registry 来解决上述问题,但因为时间所限,并未找到具体的操作方法。
针对下述镜像:gcr.io/google_containers/kube-apiserver-amd64:v1.9.0gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0gcr.io/google_containers/kube-scheduler-amd64:v1.9.0gcr.io/google_containers/kube-proxy-amd64:v1.9.0gcr.io/google_containers/etcd-amd64:3.1.10gcr.io/google_containers/pause-amd64:3.0gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7
##### 先 pull 下来docker pull gcr.io/google_containers/kube-apiserver-amd64:v1.9.0docker pull gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0docker pull gcr.io/google_containers/kube-scheduler-amd64:v1.9.0docker pull gcr.io/google_containers/kube-proxy-amd64:v1.9.0docker pull gcr.io/google_containers/etcd-amd64:3.1.10docker pull gcr.io/google_containers/pause-amd64:3.0docker pull gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7docker pull gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7docker 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.0docker tag gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0 opera443399/kube-controller-manager-amd64:v1.9.0docker tag gcr.io/google_containers/kube-scheduler-amd64:v1.9.0 opera443399/kube-scheduler-amd64:v1.9.0docker tag gcr.io/google_containers/kube-proxy-amd64:v1.9.0 opera443399/kube-proxy-amd64:v1.9.0docker tag gcr.io/google_containers/etcd-amd64:3.1.10 opera443399/etcd-amd64:3.1.10docker tag gcr.io/google_containers/pause-amd64:3.0 opera443399/pause-amd64:3.0docker tag gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7 opera443399/k8s-dns-sidecar-amd64:1.14.7docker tag gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7 opera443399/k8s-dns-kube-dns-amd64:1.14.7docker 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.0docker push opera443399/kube-controller-manager-amd64:v1.9.0docker push opera443399/kube-scheduler-amd64:v1.9.0docker push opera443399/kube-proxy-amd64:v1.9.0docker push opera443399/etcd-amd64:3.1.10docker push opera443399/pause-amd64:3.0docker push opera443399/k8s-dns-sidecar-amd64:1.14.7docker push opera443399/k8s-dns-kube-dns-amd64:1.14.7docker push opera443399/k8s-dns-dnsmasq-nanny-amd64:1.14.7##### 在目标机器上 pull 下来:docker pull opera443399/kube-apiserver-amd64:v1.9.0docker pull opera443399/kube-controller-manager-amd64:v1.9.0docker pull opera443399/kube-scheduler-amd64:v1.9.0docker pull opera443399/kube-proxy-amd64:v1.9.0docker pull opera443399/etcd-amd64:3.1.10docker pull opera443399/pause-amd64:3.0docker pull opera443399/k8s-dns-sidecar-amd64:1.14.7docker pull opera443399/k8s-dns-kube-dns-amd64:1.14.7docker 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.0docker tag opera443399/kube-controller-manager-amd64:v1.9.0 gcr.io/google_containers/kube-controller-manager-amd64:v1.9.0docker tag opera443399/kube-scheduler-amd64:v1.9.0 gcr.io/google_containers/kube-scheduler-amd64:v1.9.0docker tag opera443399/kube-proxy-amd64:v1.9.0 gcr.io/google_containers/kube-proxy-amd64:v1.9.0docker tag opera443399/etcd-amd64:3.1.10 gcr.io/google_containers/etcd-amd64:3.1.10docker tag opera443399/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0docker tag opera443399/k8s-dns-sidecar-amd64:1.14.7 gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7docker tag opera443399/k8s-dns-kube-dns-amd64:1.14.7 gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7docker 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环境2、support customize repository prefix of image through environment KUBE… #359483、Using custom images转载于:https://blog.51cto.com/nosmoking/2069950