Connect App on App Engine to cluster running on GKE

4/22/2018

I have a app running on GAE and i have a database running on google kubernetes engine. I have successfully tested the working database by forwarding port kubectl port-forward pod-name 3001:3001 and confirmed that it is working.

But my application cannot connect to it. I thought all apps within a project on Google cloud can access via localhost. Is that not true?

If not, then how do i connect my app on GAE to my database on GKE?

-- notANerdDev
google-app-engine
google-kubernetes-engine

1 Answer

4/22/2018

There are two ways:

A regular LoadBalancer which opens up the cluster to the public internet.

The other way is to use an internal LoadBalancer which only opens the traffic within google cloud.

Now, whether it opens it across the entire Gcloud network, just your projects or even just the one project is not clear to me. The docs were not clear in that regard either.

Maybe someone from Google Cloud team can help me here.

To convert a LoadBalancer service to an Internal LoadBalancer service, we add the following annotation:

  annotations:
    cloud.google.com/load-balancer-type: "Internal"

kubectl apply and then after a minute or so kubectl get services. You'll see an external ip address added to your service. The IP will be accessible to other apps on Gcloud, but not from the public internet.

-- notANerdDev
Source: StackOverflow