kubernetesnginx-ingress

Multiple external IP (load balancers) for ingress-nginx


How can I configure multiple external IPs within a single cluster using ingress-nginx?

I can see that ingress-nginx creates a load balancer service with external IP. I assume I would need to create another load balancer service? How I would indicate in ingress which load balancer to use?

PS I am using GKE.


Solution

  • Create multiple ingress controller. In new controller define a class name, (Here nginx-internal)

    spec:
     template:
        spec:
          containers:
            - name: nginx-ingress-internal-controller
              args:
                - /nginx-ingress-controller
                - '--election-id=ingress-controller-leader-internal'
                - '--ingress-class=nginx-internal'
                - '--configmap=ingress/nginx-ingress-internal-controller'
    

    Then Create a Ingress with kubernetes.io/ingress.class: "nginx-internal" annotation. For example, creating a hello-world ingress with following yaml

    
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: hello-world
      annotations:
        kubernetes.io/ingress.class: "nginx-internal"
    spec:
      tls:
      - secretName: tls-secret
      rules:
      - http:
          paths:
          - backend:
              serviceName: hello-world-svc
              servicePort: 8000
    

    Click here for official documentation