Access web server inside a pod in a vm from outside the VM

5/28/2019

I have a kubernetes cluster running on a vagrant VM. I am running a webserver listening on port 8181 on a pod inside the cluster. I activated pod port forwarding through kubectl port-forward 8180:8181 so that i can access the web-server from inside the vm. Now i'm trying to access the pod from outside the vagrant vm, that is the host machine. In the vagratfile i put config.vm.network "private_network", ip: "192.168.56.17", :adapter => 2

so taht i can access the vm through is IP(192.168.56.17). The problem is that if i try to do a curl to the webserver from the host machine i get this error: Connecting to 192.168.56.17:8180... failed: Connection refused.

I tried to run the web-server directely on the guest machine and not in the k8s pod, and i'm able to reach the web-server from the host machine, so i think it is not a problem of vagrant configuration. I tried also to activate port forwarding in Vagrant through: config.vm.network :forwarded_port, guest: 8181, host: 8181, :adapter => 2 but the problem is still here.

Thank you every one for helping me.

-- Alessio Diamanti
kubernetes
portforwarding
vagrant

0 Answers