dtzar/helm-kubectl

Cannot access the kind k8s cluster with kubectl even if the config volume is mounted

cmoulliard opened this issue · 3 comments

Issue

I created a kubernetes cluster using kind tool - https://kind.sigs.k8s.io/docs/user/quick-start/.

When I execute a kubectl get nodes cmd then I get as error The connection to the server 127.0.0.1:55112 was refused - did you specify the right host or port?

Steps to reproduce

  • $ kind create cluster
  • $ docker run -it -d --name devtools -v ~/.kube:/root/.kube dtzar/helm-kubectl
  • $ docker exec -it devtools kubectl get nodes
    The connection to the server 127.0.0.1:50168 was refused - did you specify the right host or port?

Of course, if I run the command locally without the docker container/ps, that works

kubectl get nodes
NAME                 STATUS   ROLES                  AGE   VERSION
kind-control-plane   Ready    control-plane,master   22h   v1.20.2
gaby commented

@cmoulliard Your kubeconfig is pointing to 127.0.0.1, which is different inside the container.

Change your second command to this:

docker run -it -d --net host --name devtools -v ~/.kube:/root/.kube dtzar/helm-kubectl

Many thanks for your help. Problem is fixed

gaby commented

@cmoulliard Good to hear!