How to increase nginx ingress loadbalancer replicas?

1/28/2021

I installed the nginx ingress controller via the helm chart.

Now I wan't to have multiple loadbalancers, how can I scale them up?

EDIT

I don't want to scale the nginx controllers deployment. The helm chart also added the loadbalancer and I'm wondering if I can just create a new loadbalancer or if I do have to add some annotations or smth. like that?

Also would a new loadbalancer automatically forward traffic to the existing nginx-controllers?

-- natschz
kubernetes
kubernetes-ingress
load-balancing
nginx-ingress

1 Answer

1/28/2021

you can simply scale the Nginx deployment replicas using kubectl

kubectl scale deployment <nginx-deployment-name> --replicas=5

example

kubectl scale deployment nginx-ingress-controller -n ingress-nginx --replicas=5

EDIT

annotations you can configure and add in ingress file.

For example :

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: unifonic-service-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: staging
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-body-size: "50m"
spec:
  tls:
  - hosts:
    - example.com
    secretName: staging
  rules:
  - host: example.com
    http:
      paths:
      - path: /test
        backend:
          serviceName: main-service
          servicePort: 80

if you have requirement of running multiple ingress nginx controller for managing public and internal traffic this might be helpful : https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/#multiple-ingress-nginx-controllers

https://docs.nginx.com/nginx-ingress-controller/installation/running-multiple-ingress-controllers/#running-multiple-nginx-ingress-controllers

if you want to run multiple ingress backend you can divide them by class :

 annotations:
    kubernetes.io/ingress.class: "nginx"

or

 annotations:
    kubernetes.io/ingress.class: "gce"
-- Harsh Manvar
Source: StackOverflow