标签

Honeymoon - Thomas Ng

归档

近期文章

Ubuntu安装K8S的dashboard

问题1:The connection to the server 192.168.0.37:6443 was refused – did you specify the right host or port?

root@hecs-166041:~# kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server 192.168.0.37:6443 was refused - did you specify the right host or port?

解决办法: 解决方法: 1.将主节点(master)中的“/etc/kubernetes/admin.conf”文件拷贝到从节点相同目录下

mkdir -p /root/.kube
cp -i /etc/kubernetes/admin.conf /root/.kube/config
chown root:root /root/.kube/config

2.配置环境变量

echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile

3.立即生效

source ~/.bash_profile

如果以上方法还不行,可以试一下下面的这个方法,这个方法适用于关机重启以后出现的报错: 输入 systemctl status kubelet 命令查看 kubelet 的情况,发现 kubelet 确实没有启动

问题2:Unable to connect to the server: dial tcp 172.18.10.172:6443: i/o timeout

root@hecs-166041:/work/devops/k8s/dashboard/config# kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: dial tcp 172.18.10.172:6443: i/o timeou

root@hecs-166041:~# kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://172.18.10.172:6443
  name: kubernetes
contexts:
- context:

修改成服务器的内网ip

kubectl config set-cluster kubernetes --server=https://192.168.0.37:6443

#在执行下 就改过来了
root@hecs-166041:~# kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://192.168.0.37:6443
  name: kubernetes

Buy me a cup of coffee 🙂

觉得对你有帮助,就给我打赏吧,谢谢!

微信赞赏码链接,点击跳转:

Ubuntu安装K8S的dashboard插图