Cannot access the proxy of a kubernetes pod

1/17/2020

I created a kubernetes cluster on my debian 9 machine using kind.
Which apparently works because I can run kubectl cluster-info with valid output.

Now I wanted to fool around with the tutorial on Learn Kubernetes Basics site.

I have already deployed the app

kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1

and started the kubectl proxy.

Output of kubectl get deployments

NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
kubernetes-bootcamp   1/1     1            1           17m

My problem now is: when I try to see the output of the application using curl I get

Error trying to reach service: 'dial tcp 10.244.0.5:80: connect: connection refused'

My commands

export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/

For the sake of completeness I can run curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/ and I get valid output.

-- Norbert Bartko
kubernetes

1 Answer

1/17/2020

The steps from this tutorial module represent environment as if You were working on one of the cluster nodes.

And the command tries to check connectivity to service locally on the node.

However In Your case by running Your kubernetes in a docker (kind) cluster the curl command is most likely ran from the host that is serving the docker containers that have kubernetes in it.

It might be possible to use docker exec to get inside kind node and try to run curl command from there.

Hope this helps.

-- Piotr Malec
Source: StackOverflow