kubectl运行命令失败,出现连接拒绝错误 [英] kubectl run command is failing with a connection refused error

查看:398
本文介绍了kubectl运行命令失败,出现连接拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在kubernetes.io上的hellonode教程

I am following the hellonode tutorial on kubernetes.io

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

尝试执行创建您的广告连播"部分时出现错误.

I am getting an error when trying to do the 'Create your pod' section.

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

When I run this command (replacing PROJECT_ID with the one I created) I get the following:

$ 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版本也会遇到类似的错误:

I get a similar error just typing 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的经验.

I'm not sure what to do since I have no experience with kubernetes other than following the steps of this tutorial.

推荐答案

我发现了问题所在. 在Create your cluster部分中,我错过了关键步骤.

I figured out the issue. In the Create your cluster section I missed a critical step.

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

The step I missed was: Please ensure that you have configured kubectl to use the cluster you just created. The configured part is a link to how to do this:

步骤如下:

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

这篇关于kubectl运行命令失败,出现连接拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆