Linux搭建K8S,内网(无外网)的主机上的Docker如何下载外网镜像

我们在腾讯云上有3台主机,准备搭建K8S,为了省钱,只有一台主机有外网,于是,把外网机做k8s-master, 两台内网机做node1,node2。这需要在另外两台主机上做如下设置,才能保证内网机可以下载docker镜像。

  1. 在外网机上安装squid
  2. 在内网机上设置:
    vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://10.206.16.3:3128/" "HTTPS_PROXY=http://10.206.16.3:3128/" "NO_PROXY=localhost,127.0.0.1,10.*.*.*"
  1. 设置环境变量:
export http_proxy="http://10.206.16.3:3128/"
export https_proxy="http://10.206.16.3:3128/"
export no_proxy="localhost,10.0.0.0/8"

另外,由于国内无法访问google, K8S需要的安装包可以用如下阿里镜像,直接上命令:

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.23.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.23.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.23.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.23.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.1-0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.8.6

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.23.3 k8s.gcr.io/kube-apiserver:v1.23.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.23.3 k8s.gcr.io/kube-controller-manager:v1.23.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.23.3 k8s.gcr.io/kube-scheduler:v1.23.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.23.3 k8s.gcr.io/kube-proxy:v1.23.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6 k8s.gcr.io/pause:3.6
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.1-0 k8s.gcr.io/etcd:3.5.1-0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.8.6 k8s.gcr.io/coredns/coredns:v1.8.6

docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.23.3
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.23.3
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.23.3
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.23.3
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.1-0
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.8.6
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值