ingress-nginx: Nginx Controller serving ingress objects where ingressclass annotation does not match controller class

NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):

Kubernetes version (use kubectl version): v1.19.14

Environment:

  • Cloud provider or hardware configuration: GCP (GKE)

  • OS (e.g. from /etc/os-release):

  • Kernel (e.g. uname -a):

  • Install tools:

    • helm chart ingress-nginx/ingress-nginx
  • Basic cluster related info:

    • kubectl version v1.19.14
    • kubectl get nodes -o wide 6 nodes
  • How was the ingress-nginx-controller installed: Using helm values file:

controller:
  ingressClassResource:
    name: nginx-public
    controllerValue: k8s.io/nginx-public
  replicaCount: 2
  service:
    loadBalancerIP: 0.0.0.0
    externalTrafficPolicy: "Local"
  extraArgs:
    default-ssl-certificate: "default/example-wildcard"
  config:
    ssl-redirect: "true"
    force-ssl-redirect: "true"
  • Current State of the controller:
    • kubectl get ingressclasses
  NAME           CONTROLLER            PARAMETERS   AGE
nginx-public   k8s.io/nginx-public   <none>       19m
  • Current state of ingress object, if applicable:

    • kubectl -n <appnnamespace> get all,ing -o wide
    • kubectl -n <appnamespace> describe ing <ingressname>
    • If applicable, then, your complete and exact curl/grpcurl command (redacted if required) and the reponse to the curl/grpcurl command with the -v flag
  • Others:

    • Any other related information like ;
      • copy/paste of the snippet (if applicable)
      • kubectl describe ... of any custom configmap(s) created and in use
      • Any other related information that may help

What happened: There are two ingress classes.

  1. nginx (old deployment, has no ingressclass resource in cluster)
  2. nginx-public (new deployment, has ingressclass resource in cluster)

The nginx-public controller is watching and serving ingress objects where ingress.class annotation is set to class nginx and spec.IngressClassName is not set.

If spec.IngressClassName is set to nginx the issue is fixed.

What you expected to happen: The controller A should not serve controller B ingress objects when ingress class annotation is set to controller B.

How to reproduce it:

Anything else we need to know:

/kind bug

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

hi, you need to check the run parameters for the nginx ingress controller. If you want the second ingress controller to serve only the nginx ingress class you created (nginx-public), you need to add to your current ingress controller values the following items:

controller:
  ...
  ingressClassByName: true
  extraArgs:
    ingress-class: nginx-public

That is the only way i managed to have 1 ingress controller serve 1 ingress class. For reference, i checked the parameters that are passed to the ingress controller at startup here and checked what they do here