Search code examples
kubernetesgoogle-kubernetes-enginekubernetes-ingressnginx-ingress

GKE Can't have multiple ingress nginx anymore?


In the past I've installed them using:

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update

helm install ingress-nginx-01 ingress-nginx/ingress-nginx

and could have multiple.

Now I'm getting this error when I try to install another:

Error: rendered manifests contain a resource that already exists. Unable to continue with
install: IngressClass "nginx" in namespace "" exists and cannot be imported into the
current release: invalid ownership metadata; annotation validation error: key
"meta.helm.sh/release-name" must equal "ingress-nginx-02": current value is
"ingress-nginx-01"; annotation validation error: key
"meta.helm.sh/release-namespace" must equal "ingress-02": current value is "ingress-01"

Solution

  • You have to set the Class Name while installing the new Nginx ingress controller again.

    For example :

    helm install stable/nginx-ingress --set controller.ingressClass=gce --namespace kube-system --set controller.replicaCount=2 --set rbac.create=false
    helm install stable/nginx-ingress --set controller.ingressClass=nginx --namespace kube-system --set controller.replicaCount=2 --set rbac.create=false
    helm install stable/nginx-ingress --set controller.ingressClass=third --namespace kube-system --set controller.replicaCount=2 --set rbac.create=false
    

    based on your helm version you can pass the name of Helm as you did ingress-nginx-01, ingress-nginx-02 but main thing is class name: --set controller.ingressClass=gce

    as error says

    install: IngressClass "nginx" in namespace "" exists**strong text**
    

    Multiple Ingress controllers

    If you're running multiple ingress controllers or running on a cloud provider that natively handles ingress such as GKE, you need to specify the annotation kubernetes.io/ingress.class: "nginx" in all ingresses that you would like the ingress-nginx controller to claim.

    For instance,

    metadata:
      name: foo
      annotations:
        kubernetes.io/ingress.class: "gce"
    

    will target the GCE controller, forcing the Nginx controller to ignore it, while an annotation like

    metadata:
      name: foo
      annotations:
        kubernetes.io/ingress.class: "nginx"
    

    will target the nginx controller, forcing the GCE controller to ignore it.

    Example : https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/

    Ref : https://vincentlauzon.com/2018/11/28/understanding-multiple-ingress-in-aks/