Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

did you specify the right host or port? error on Kubernetes

I have followed the helloword tutorial on http://kubernetes.io/docs/hellonode/.

When I run:

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

I get:

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

Why does the command line try to connect to the localhost?

like image 476
poiuytrez Avatar asked Apr 15 '16 15:04

poiuytrez


People also ask

What is host port in Kubernetes?

The hostPort feature allows to expose a single container port on the host IP. Using the hostPort to expose an application to the outside of the Kubernetes cluster has the same drawbacks as the hostNetwork approach discussed in the previous section.

Which ports should be open for Kubernetes?

The ports required for a Kubernetes deployment are: 2379/tcp: Kubernetes etcd server client API (on master nodes in multi-master deployments) 2380/tcp: Kubernetes etcd server client API (on master nodes in multi-master deployments) 6443/tcp: Kubernetes API server (master nodes)

How do you solve the connection to the server localhost 8080 was refused Did you specify the right host or port?

This is a common issue when you run the kubectl command or a similar command. In most cases, Kubernetes does not have the correct credentials to access the cluster. It can be easily resolved easily by setting an environment variable in most similar cases.

How do I find my Kubernetes port?

Access the Kubernetes Dashboard from your browser Then, navigate to: http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ and you should see your Kubernetes dashboard and information.


1 Answers

The issue is that your kubeconfig is not right. To auto-generate it run:

gcloud container clusters get-credentials "CLUSTER NAME" 

This worked for me.

like image 85
Alan Wagner Avatar answered Nov 19 '22 17:11

Alan Wagner