kubernetes - GCP GKE Google Kubernetes Engine 连接到服务器 localhost :8080 was refused

标签 kubernetes google-cloud-platform google-cloud-storage google-kubernetes-engine kubernetes-pod

我正在尝试 GCP 和 GKE google kubernetes 引擎。 1-)我正在创建一个集群 2-) 我打开云外壳并使用命令“kubectl get nodes”

我收到这个错误: “与服务器 localhost:8080 的连接被拒绝 - 您是否指定了正确的主机或端口?”

我该如何解决。谢谢。

最佳答案

您必须有一个本地 Kubernetes 配置文件,kubectl 使用它来访问集群。

通常,配置文件称为 config (YAML),位于 ${HOME}/.kube/config 中。

Google 提供了一种为您生成配置文件(和上下文)的方法。为此,请运行 gcloud container clusters get-credentials ...。您需要填写集群名称的空白,可能还有项目、区域/区域等:

gcloud container clusters get-credentials ${CLUSTER_NAME} \
--project=${PROJECT} \
--region=${REGION}

运行此命令后,您应该能够more ${HOME}/.kube/config 并且您应该能够使用例如访问集群kubectl 获取节点

关于kubernetes - GCP GKE Google Kubernetes Engine 连接到服务器 localhost :8080 was refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72143177/

相关文章:

google-cloud-platform - GCP Dataproc - 错误 : Unknown name "optionalComponents" at 'cluster.config' : Cannot find field

google-cloud-platform - 使用 Cloud Shell 连接到 Google Cloud SQL 时出现问题

java - 照片未正确上传 GCS App Engine

java - 尝试访问部署在 K8s/Argocd 服务器上的 Spring 后端时出现 "required audience is missing"

kubernetes - kubernetes 上的 prometheus 节点导出器

kubernetes - 安装ingress-nginx helm chart出错

google-cloud-messaging - 从 Google 项目 ID 获取 Google 帐户所有者

python-3.x - Python unittest.mock google storage - 如何实现 exceptions.NotFound 作为副作用

python - Google Cloud Storage - 如何通过 Python 检索文件的所有者?

docker - 我们可以更新docker默认配置吗?