How do you access compute engine instance using internal ip from Google Kubernetes Engine pod in same zone?

8/16/2018

I am looking to access a Postgres service outside of GKE, but on a compute engine VM in the same zone using the VMs internal IP.

So far I've managed to access it via the external IP from inside the pod, but I'm looking to access it without leaving google infrastructure.

I have done some testing and I can SSH into the kubernetes VM and connect to the other VM using the internal IP, but when I attempt to do this from the pod running on the VM it cannot connect. I even tried using the compute engine internal DNS name with the same result, success from the VM but unable to connect from the pod.

I am sure this isn't the first time this problem has come up but I cannot find out a way to communicate from the kubernetes pod to a compute engine instance in the same zone.

-- Ryan McCue
google-cloud-platform
google-compute-engine
google-kubernetes-engine
kubernetes

1 Answer

8/16/2018

It turns out with the compute engine VM I did not have the kubernetes pod address range whitelisted for port 5432. I simply added that to the network configuration for the VM and it started working...

-- Ryan McCue
Source: StackOverflow