首页 > 解决方案 > Kubernetes 连接在端口 8080 上被拒绝 - Windows 10

问题描述

kubectl通过 安装后,我在 Windows10 上出现以下错误choco install kubernetes-cli

PowerShell

PS C:\Users\userA> kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

Cmd

C:\Users\userA>kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

我创建了.kube文件夹 ( C:\Users\userA\.kube) 并在其中创建了一个空config文件

我设置了windows环境变量:

Variable_name: KUBECONFIG value:C:\Users\userA\.kube\config

编辑:我用runningminikube 测试了它:

在此处输入图像描述

标签: cmdkuberneteswindows-10environment-variables

解决方案


您需要先启动服务器,使用:

minikube start

编辑:当 op 尝试使用 hyper-v 时,以下命令告诉 minikube 使用 hyper-v

minikube start --vm-driver hyperv --hyperv-virtual-switch "Primary Virtual Switch"

为了实现这个工作,还需要在 hyper-v 中设置一个名为“Primary Virtual Switch”的虚拟交换机。


推荐阅读