Using NGINX on-prem as LB for kubernetes

10/19/2018

I already had NGINX handling my reverse-proxy and load balancing for bare-metals and VMs, wonder if I can use the same instance for my Kubernetes cluster exposing services in load-balancer mode. If so, could I use it for both L4 and L7?

-- Sam Wang
kubernetes
nginx

1 Answer

10/20/2018

You can't use it as type LoadBalancer because there's no cloud-provider API to handle an external Nginx instance. You can do a couple of things I can think of:

  1. Create Kubernetes Service exposed on a NodePort. So your architecture will look like this:

    External NGINX -> Kubernetes NodePort Service -> Pods
  2. Create a Kubernetes Ingress managed by an ingress controller. The most popular happens to be Nginx. So your architecture will look something like this:

    External NGINX -> Kubernetes Service (has to be NodePort) -> Ingress (NGINX) -> Backend Service -> Pods
-- Rico
Source: StackOverflow