1

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?

guettli
  • 3,113
  • 14
  • 59
  • 110

1 Answers1

0

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.

guettli
  • 3,113
  • 14
  • 59
  • 110