您的位置:首页 > 运维架构 > Docker

k8s在下载docker镜像时无法连接外网

2019-08-07 17:21 225 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/weixin_41609807/article/details/98764144

 

could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k 8s.io/release/stable-1.txt": Gethttps://dl.k8s.io/release/stable-1.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

在执行kubeadm config images pull失败时,修改镜像的地址。此镜像地址是由微软提供的https://github.com/Azure/container-service-for-azure-china/blob/master/aks/README.md

第一种:推荐构建私有镜像库

第二种:创建文件kubeadm.yaml:主要注意中间对imageRepository: gcr.azk8s.cn/google_containers对默认仓库的更改。默认的配置通过kubeadm config print init-defaults指令可以查看

[code]apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.137.88
bindPort: 6443
nodeRegistration:
taints:
- effect: PreferNoSchedule
key: node-role.kubernetes.io/master
---
apiVersion: kubeadm.k8s.io/v1beta2
imageRepository: gcr.azk8s.cn/google_containers
kind: ClusterConfiguration
kubernetesVersion: v1.15.2
networking:
podSubnet: 10.244.0.0/16

配置完成后测试:kubeadm config images pull成功后可执行。

[code]kubeadm init --config kubeadm.yaml --ignore-preflight-errors=Swap

如果出错可以使用 kubeadm reset 进行回退。

 kubeadm config images list  通过这个指令查看使用的镜像文件。

 

第三种:生产默认配置文件修改文件中的镜像地址,镜像地址上面已经给出

kubeadm config print init-defaults --api-objects ClusterConfiguration >kubeadm.conf

改为你自己的私有docker仓库,比如

imageRepository: gcr.azk8s.cn/google_containers

然后运行命令

[code]kubeadm config images list --config kubeadm.conf
kubeadm config images pull --config kubeadm.conf
kubeadm init --config kubeadm.conf

安装参考文档

         内部的个别bug是可参考本文章 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: