kubectl run 命令失败并出现连接被拒绝错误

2024-01-02

我正在关注 kubernetes.io 上的 hellonode 教程

http://kubernetes.io/docs/hellonode/ http://kubernetes.io/docs/hellonode/

我在尝试执行“创建您的 Pod”部分时遇到错误。

当我运行此命令(将 PROJECT_ID 替换为我创建的命令)时,我得到以下信息:

$ kubectl run hello-node --image=gcr.io/PROJECT_ID/hello-node:v1 --port=8080

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

我只需输入 kubectl version 就会遇到类似的错误:

$ kubectl version

Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.2", GitCommit:"528f879e7d3790ea4287687ef0ab3f2a01cc2718", GitTreeState:"clean"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

我不知道该怎么做,因为除了遵循本教程的步骤之外,我没有任何 Kubernetes 经验。


我想通了这个问题。 在里面Create your cluster我错过了一个关键步骤。

我错过的步骤是:Please ensure that you have configured kubectl to use the cluster you just created.配置部分是如何执行此操作的链接:

步骤如下:

gcloud config set project PROJECT
gcloud config set compute/zone ZONE
gcloud config set container/cluster CLUSTER_NAME
gcloud container clusters get-credentials CUSTER_NAME
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

kubectl run 命令失败并出现连接被拒绝错误 的相关文章

随机推荐