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

10/26/2020

I'm trying to use KIND to spin up my Kubernetes cluster and trying to use it with Kubectl but I'm stymied at the first hurdle

I set up a cluster using the following kind config

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
    - hostPort: 80
      containerPort: 80

Then I use kubectl

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

This makes sense because if I do docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                       NAMES
9dcd3b6fd19d        kindest/node:v1.17.11   "/usr/local/bin/entr…"   14 minutes ago      Up 14 minutes       127.0.0.1:44609->6443/tcp   kind-control-plane

What do I have to do to start the kubernetes API server and get the nodes on it?

-- cjds
kind
kubernetes

1 Answer

2/12/2021

I solve this issue with sudo chmod 0644 /etc/kubernetes/admin.conf and export KUBECONFIG=/etc/kubernetes/admin.conf

-- Frank N Stein
Source: StackOverflow