error: failed to create token: Post "http://localhost:8080/api/v1/namespaces/kube-system/serviceaccounts/admin-user/token": dial tcp [::1]:8080: connect: connection refused [root@k8s-node-2 ~]# kubectl cluster-info E0605 09:11:48.387028 2716053 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused E0605 09:11:48.387335 2716053 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused E0605 09:11:48.388415 2716053 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused E0605 09:11:48.389705 2716053 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused E0605 09:11:48.390997 2716053 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. The connection to the server localhost:8080 was refused - did you specify the right host or port?
时间: 2024-04-27 18:22:23 浏览: 325
根据错误信息,连接到Kubernetes API服务器时出现了拒绝连接的错误。这可能是由于以下原因之一导致的:
Kubernetes API服务器未运行:请确保Kubernetes API服务器正在运行。您可以通过运行以下命令来检查API服务器是否正在运行:
sudo systemctl status kube-apiserver
如果API服务器未运行,请尝试启动它:
sudo systemctl start kube-apiserver
API服务器地址或端口不正确:请确保您正在使用正确的API服务器地址和端口。默认情况下,kubectl将尝试连接到本地主机的8080端口。如果您的API服务器在不同的地址或端口上运行,请使用以下命令手动指定API服务器地址和端口:
kubectl cluster-info --server=<API-server-address>
请将
<API-server-address>
替换为实际的API服务器地址和端口。kubectl无法访问kubeconfig文件:请确保您的kubectl正在使用正确的
kubeconfig
文件。kubeconfig
文件包含与Kubernetes集群的连接信息。您可以使用以下命令检查当前使用的kubeconfig
:kubectl config view
如果需要,可以使用以下命令切换到其他
kubeconfig
文件:kubectl config use-context <context-name>
请将
<context-name>
替换为要使用的context
的名称。防火墙或网络问题:请确保可以从kubectl到达Kubernetes API服务器的网络路径没有被防火墙或其他网络设备阻塞。另外,请确保网络连接正常。
如果上述解决方法都无法解决问题,请提供更多上下文信息以便我更好地帮助您解决问题。
相关推荐


















