Score:0

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

cn flag

I created a second context in my local kind-cluster:

The first context works:

kubectl get pods

NAME                                              READY   STATUS    RESTARTS      AGE
dashboard-kubernetes-dashboard-76bd8dc445-wp9l6   1/1     Running   5 (26h ago)   10d
foo-5c9ff58bf4-c5mgh                              1/1     Running   3 (26h ago)   14d

I created a second context, but this can't connect:

kubectl --context=DevDan-context get pods


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

What could be wrong?

Score:0
cn flag

I found the solution by looking at .kube/config

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS...==
    server: https://127.0.0.1:43437
  name: kind-kind
contexts:
- context:
    cluster: kubernetes
    namespace: development
    user: DevDan
  name: DevDan-context
- context:
    cluster: kind-kind
    user: kind-kind
  name: kind-kind
...

The DevCan context uses a cluster called "kubernetes", while the other context uses the "kind-kind".

The cluster "kubernetes" is not configured in the config. After changing it to "kind-kind" it worked.

It is a bit strange, that kubectl does not complain, that the cluster named "kubernetes" is not configured. It seems to default to localhost:8080.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.