k8s install kubeadm网络原因访问不了谷哥and gpg: no valid OpenPGP data found. 解决办法

gpg: no valid OpenPGP data found. 解决办法

待做。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

卡助在这
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

解决方法:http://windgreen.me/2018/02/23/%E5%9B%BD%E5%86%85%E4%BD%BF%E7%94%A8kubernetes%E8%B8%A9%E8%BF%87%E7%9A%84%E5%9D%91/

因为无法访问谷歌,所以会卡在curl这一步。那么解决方案当然就是翻墙。

我这里国外服务器上安装有SS,如果没有SS服务器,直接用ssh tunnel应该是可以的。有ss的话本地需要使用ss local。所以建议使用docker来运行ss,这样用完即删,很方便。

我用的镜像是:https://hub.docker.com/r/mritd/shadowsocks/

准备好国外服务器后,在国内服务器上安装tsocks

编辑 vi /etc/tsocks.conf

server是本地Ip

server_type 5 就是socks5的意思

server_port 本地代理端口,跟ss_local一样就行。

准备好梯子后,开始安装软件

这里要注意一个问题是,如果国内用的是阿里云服务器,那么源可能用的是内网地址,这样直接用tsocks执行apt update会出下面这样的错误

W: The repository ‘http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates Release’ does not have a Release file.

或者

Err:9 http://mirrors.cloud.aliyuncs.com/ubuntu xenial Release
Connection failed

这时候 vi /etc/apt/source.list.d/source.aliyun.list

将所有 http://mirrors.cloud.aliyuncs.com改为http://mirrors.aliyun.com就能使用代理update,改之前可以备份一个,用完再改回内网。

安装好软件后,会卡在kubeadm init,使用tsocks kubeadm init并不能解决问题。

unable to get URL “https://dl.k8s.io/release/stable-1.9.txt”: Get https://storage.googleapis.com/kubernetes-release/release/stable-1.9.txt: dial tcp 172.217.160.112:443: i/o timeout

这里我们指定kubernetes vuersion来跳过这个,

kubeadm init –kubernetes-version=1.9.3

如果没有提前准备镜像,一般会卡在这里

[init] This might take a minute or longer if the control plane images have to be pulled.

Unfortunately, an error has occurred:Unfortunately, an error has occurred: timed out waiting for the condition
This error is likely caused by: – The kubelet is not running – The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled) – There is no internet connection, so the kubelet cannot pull the following control plane images: – gcr.io/google_containers/kube-apiserver-amd64:v1.9.3 – gcr.io/google_containers/kube-controller-manager-amd64:v1.9.3 – gcr.io/google_containers/kube-scheduler-amd64:v1.9.3

所以我们需要提前准备好镜像。我使用的办法是在那台国外服务器上pull下镜像,再push到hub.docker.com,然后再从hub.docker.com pull到国内服务器。

这是写好的脚本,在国外服务器运行,将其中的<username>和<password>换成你的hub.docker.com帐号密码就行。

在国内再运行下面这个脚本

这样,就把kubernetes需要的镜像都准备好了。再执行init就不会有问题了。

另外有一个小技巧,在init的过程中,另开一个终端,运行

journalctl -f -u kubelet.service

可以查看具体是什么愿意卡住了。

原文地址:https://www.cnblogs.com/Tom-yi/p/k8s.html