如何解决``无法连接到服务器:EOF''Kubernetes的问题-Kubectl

Car*_*res 17 kubernetes kubectl

当我尝试任何kubectl命令时,它总是返回:

Unable to connect to the server: EOF
Run Code Online (Sandbox Code Playgroud)

我遵循了这些教程:

https://kubernetes.io/docs/tasks/tools/install-kubectl/

https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/

但是他们没有帮助我。根据第一个链接,默认情况下,kubectl配置位于

~/.kube/config
Run Code Online (Sandbox Code Playgroud)

但是在那条路上我什么都没有。我不知道这是否是导致问题的原因。

另一件事是当我尝试检查kubectl配置时:

M:.kube candres$ kubectl cluster-info
Kubernetes master is running at http://localhost:8080

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Unable to connect to the server: EOF
M:.kube candres$ kubectl cluster-info dump
Unable to connect to the server: EOF
Run Code Online (Sandbox Code Playgroud)

我安装的版本是:

Kubernetes-Kubectl

M:.kube candres$ kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"X", GitTreeState:"clean", BuildDate:"2018-02-09T21:51:06Z", GoVersion:"go1.9.4", Compiler:"gc", Platform:"darwin/amd64"}
Unable to connect to the server: EOF
Run Code Online (Sandbox Code Playgroud)

迷你库

M:.kube candres$ minikube version
minikube version: v0.25.0
Run Code Online (Sandbox Code Playgroud)

码头工人:

M:.kube candres$ docker version
Client:
 Version:   17.12.0-ce
 API version:   1.35
 Go version:    go1.9.2
 Git commit:    X
 Built: Wed Dec 27 20:03:51 2017
 OS/Arch:   darwin/amd64

Server:
 Engine:
  Version:  17.12.0-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.2
  Git commit:   X
  Built:    Wed Dec 27 20:12:29 2017
  OS/Arch:  linux/amd64
  Experimental: true
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?

Sur*_*noi 7

在启动Minikube之后,将自动配置kubectl

minikube start
Starting local Kubernetes cluster...
Kubernetes is available at https://192.168.99.100:8443.
Kubectl is now configured to use the cluster.
Run Code Online (Sandbox Code Playgroud)

您可以使用以下命令来验证和验证集群和上下文。

kubectl config view
Run Code Online (Sandbox Code Playgroud)


Nap*_*tir 5

我也有这个问题。请务必检查由 生成的配置文件minikube。该文件很可能可以找到~/.kube/config。确保您在当前使用的上下文中引用正确的集群名称。您可以通过以下方式查看当前正在使用的上下文:kubectl get current-context。重要的是,您了解为什么会收到此错误,并且正如@Suresh Vishnoi 所说,kubectl不了解k8sapi-server。

  • 在 2020 年 12 月 3 日写这篇文章时,同时学习 Kubernetes 和“kubectl get current-context”不起作用。使用“kubectl config current-context”查看当前上下文 (2认同)