我正在尝试解决以下问题:
kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.6", GitCommit:"dff82dc0de47299ab66c83c626e08b245ab19037", GitTreeState:"clean", BuildDate:"2020-07-15T16:58:53Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: dial tcp 192.168.0.10:6443: i/o timeout
我在我试图解决的一些stackoverflow帖子中找到了答案
$kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://192.168.0.10:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
然后,我编写了以下命令,并在下面得到了该命令:
$ kubectl config use-context docker-for-desktop
error: no context exists with the name: "docker-for-desktop"
然后我正在运行sudo docker ps,我在下面得到这张图片:
如何解决Unable to connect to the server
错误?
答案 0 :(得分:1)
Unable to connect to the server: dial tcp 192.168.0.10:6443: i/o timeout
以上错误表示应该在端口6443
上侦听的Kubernetes API Server在kubeadm init
进程中未运行。可以通过sudo docker ps | grep api
禁用交换和重新启动计算机
sudo swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab
通过运行以下命令来卸载并重新安装kubernetes
sudo kubeadm reset -f
sudo kubeadm init
如果要在本地系统上尝试kubernetes,则建议使用minikube或kind代替kubeadm。