kubernetes - kubectl 安装错误 - 连接到服务器 localhost :8080 was refused - did you specify the right host or port

标签 kubernetes kubectl kops

我正在尝试在 AWS 上安装 kops 集群,作为先决条件,我按照提供的这些说明安装了 kubectl,

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

但是当我尝试验证安装时,出现以下错误。

ubuntu@ip-172-31-30-74:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:57:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

我不知道为什么!因为我之前已经用类似的方式设置了集群并且一切正常。
现在想建立一个新的集群,但有点卡在这里。

任何帮助表示赞赏。

最佳答案

The connection to the server localhost:8080 was refused - did you specify the right host or port?



此错误通常意味着您的 kubectl 配置不正确,并且指向错误的地址或凭据错误。

如果您已经使用 kops 成功创建了集群,则只需将其连接设置导出到 kubectl config。
kops export --name=<your_cluster_name> --config=~/.kube/config

如果要为此集群使用单独的配置文件,可以通过设置环境变量来实现:
export KUBECONFIG=~/.kube/you_cluster_name.config
kops export kubecfg --name you_cluster_name --config=~$KUBECONFIG

您还可以使用 KOPS_STATE_STORE 为每个团队成员创建 kubectl 配置:
export KOPS_STATE_STORE=s3://<somes3bucket>
# NAME=<kubernetes.mydomain.com>
kops export kubecfg ${NAME}

关于kubernetes - kubectl 安装错误 - 连接到服务器 localhost :8080 was refused - did you specify the right host or port,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51265483/

相关文章:

zsh - 如何为 zsh 安装 kubectl 自动完成插件?

docker - 使用docker daemon连接到Kubernetes kops pod

Kubernetes nginx入口 Controller 坏网关

yaml - kubectl YAML 配置文件等效于 "kubectl run ... -i --tty ..."

elasticsearch - Kubernetes:在VPN内部公开服务

kubernetes - 使用 kubectl 列出给定命名空间中的所有对象

kubernetes:通过 kops 部署时的 CA 文件

linux - 主节点的 Kops 滚动更新失败并显示 "Cluster did not pass validation"

python - Python和套接字-连接到特定路径

django - 在kubernetes上使用Nginx和Gunicorn提供Django静态文件