之前,我已经成功地使用“kubeadm init”部署了一个k8s集群。遇到问题时,我会重新安装k8s。现在,我重新部署了k8s集群失败!

Linux操作系统

uname -a
Linux kube-master 4.15.0-33-generic #36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

k8s env
kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:14:39Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

我的部署命令:
sudo kubeadm -v 10 init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.0.100 --kubernetes-version v1.11.2

[init] this might take a minute or longer if the control plane images have to be pulled
I0828 17:12:47.780302   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'
I0828 17:12:47.780492   28675 round_trippers.go:405] GET https://192.168.0.100:6443/healthz?timeout=32s  in 0 milliseconds
I0828 17:12:47.780500   28675 round_trippers.go:411] Response Headers:
I0828 17:12:48.280824   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'
I0828 17:12:48.281238   28675 round_trippers.go:405] GET https://192.168.0.100:6443/healthz?timeout=32s  in 0 milliseconds
I0828 17:12:48.281283   28675 round_trippers.go:411] Response Headers:
I0828 17:12:48.780836   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'
I0828 17:12:48.781171   28675 round_trippers.go:405] GET https://192.168.0.100:6443/healthz?timeout=32s  in 0 milliseconds
I0828 17:12:48.781199   28675 round_trippers.go:411] Response Headers:
I0828 17:12:49.281440   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'

谁能帮我?

最佳答案

kubeadm init之后,您应该将admin.conf文件复制到将使用kubectl命令的用户的主目录中,并将配置路径设置为KUBECONFIG系统变量:

sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf

它是一个配置文件,其中kubectl读取与K8s群集建立连接所需的详细信息。

关于kubernetes - 部署k8s集群,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52055326/

10-15 20:02