Kubernetes resolving backend IP

7/20/2018

enter image description here

My backend and frontend is deployed on Google Kubernetes Engine (GKE). And lets consider these steps -

  1. User opens up browser and points to yyy.yyy.yyy:8080.
  2. Browser loads the login page.
  3. User enters username/password and presses "login" button.
  4. Browser (ReactJS App) sends request to REST backend xxx.xxx.xxx:7070 to do the validation.

Now my question is, how can we inject the backend (in this case xxx.xxx.xxx) ip frontend pod? Because this ip is not static (i dont want to make it static), and will be provided by GKE. I don't want to proxy my backend call through frontend either. Neither I want to use nginx, the reason is, one more POD, and config to maintain. Just don't want to have nginx for only this reason.

Should I create ingress? I mean something like-

`/`      <-- serves ReactJS app

`/api`   <--- serves REST api

Or there is a way to inject the ip of backend POD?

What is the best approach?

Thanks in advance.

-- Jahid Shohel
google-kubernetes-engine
kubernetes
kubernetes-ingress

1 Answer

7/20/2018

You can't access the pods directly from the outside. The only way in is through a service of type LoadBalancer. External IP you get for such a service is static for GKE (AWS gives a DNS name instead)

For every service of type LoadBalancer the cloud provider will spin up a load balancer that you have to pay for. You can funnel all http traffic through a single ingress service that would fan out your requests based on host DNS or URI path and other options. Which is what pretty much everyone does. If you want to setup something like that google for ingress

-- Lev Kuznetsov
Source: StackOverflow