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

9/13/2018

When I want to execute this command:

kubectl apply -f namespace.yaml

I had this error message:

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

Some answers have been posted in Stackoverflow like using kubectl with:

--kubeconfig=~/.kube/config

But this didn't solve my problem.

This is my namespace.yaml file:

apiVersion: v1
kind: Namespace
metadata:
  name: my_namespace

I'm using GKE (1.10.6-gke.3).

-- 4m1nh4j1
google-kubernetes-engine
kubernetes

1 Answer

9/13/2018

You need to configure kubectl to use your cluster as described here: https://cloud.google.com/kubernetes-engine/docs/quickstart

-- Lev Kuznetsov
Source: StackOverflow