Kubernetes pod to GCP Compute Engine VM communication

2/9/2021

How can I connect to VM's running in GCP compute engine from Kubernetes pod? I have setup a proxy server in Compute Engine and I need to use that from within pods.

This communication needs to be using internal IP. I have allowed firewall rules to allow all internal IP.

Any suggestions on how to connect from pods to gcp vm's?

-- John Doe
google-cloud-platform
kubernetes

1 Answer

2/9/2021

You can create an internal load balancer in GCP and connect VM or you can use the VPC peering if in a different network.

  • If your GKE and VM are in the same network you can use the internal IP of your VM to connect with.

From inside of POD you can send curl requests to the VM over internal IP.

OR

  • If your GKE and GCP VM both are in the different networks you can use the VPC peering to connect both networks and use the internal IP of VM from POD.
-- Harsh Manvar
Source: StackOverflow