<p>I have some services running in Kubernetes. I need an NGINX in front of them, to redirect traffic according to the URLs, handle SSL encryption and load balancing.</p>

<p>There is a working nginx.conf for that scenario. What I´m missing is the right way to set up the architecture on gcloud.</p>

<p>Is it correct to launch a StatefulSet with nginx and have a Loadbalancing Service expose NGINX? Do I understand it right, that gcloud LB would pass the configured Ports ( f.e. 80 + 443) to my NGINX service, where I can handle the rest and forward the traffic to the backend services?</p>

Alex Tbk
<p>You don't really need a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSet</a>, a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">Deployment</a> will do since nginx is already being fronted by a gcloud TCP load balancer, if for any reason one of your nginx pods is down the gcloud load balancer will not forward traffic to it. Since you already have a gcloud load balancer you will have to use a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer">NodePort</a> <a href="https://kubernetes.io/docs/concepts/services-networking/service" rel="nofollow noreferrer">Service</a> type and you will have to point your gcloud load balancer to all the nodes on your K8s cluster on that specific port.</p>

<p>Note that your <code>nginx.conf</code> will have to know how to route to all the services internally in your K8s cluster. I recommend you set up an <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">nginx ingress controller</a>, which will basically manage the <code>nginx.conf</code> for you through an <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress</a> resource and you can also expose it as a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer" rel="nofollow noreferrer">LoadBalancer</a> Service type.</p>
