Skip to content

Nginx IngressClass use the wrong controller #381

@stalb

Description

@stalb

Summary

In the new version of the ingress add-on, based on trafik instead of ingress-nginx, there is a IngressClass 'nginx',
which should works as ingress-nginx compatible provider
(reference: https://doc.traefik.io/traefik/reference/install-configuration/providers/kubernetes/kubernetes-ingress-nginx/).

However the IngressClass 'nginx' created buy the add-on use the traefik.io/ingress-controller provider, instead of the traefik providers.kubernetesIngressNginx.controllerClass which is k8s.io/ingress-nginx.

Nginx IngressClass defined in the add-on:

# IngressClass 'nginx' - for users with existing nginx ingress resources
- apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: nginx
spec:
controller: traefik.io/ingress-controller

Traefik's ingress-nginx compatible provider defined in traefik helm chart:

https://github.com/traefik/traefik-helm-chart/blob/20a237feeeb5b541dae0b99bcdea8b94fae210a1/traefik/values.yaml#L368-L374

  kubernetesIngressNginx:
    # -- Enable Kubernetes Ingress NGINX provider (experimental)
    enabled: false
    # -- Ingress Class Controller value this controller satisfies
    controllerClass: "k8s.io/ingress-nginx"
    # -- Name of the ingress class this controller satisfies
    ingressClass: "nginx"

So currently, the IngressClass 'nginx' is managed by the standard traefik provider instead of the ingress-nginx compatible one.

What Should Happen Instead?

The IngressClass 'nginx' should use the ingress-nginx compatible provider.

Reproduction Steps

  1. Install a recent version of the ingress addon: microk8s enable ingress -V 39.0.0
  2. Install a app using an ingress with spec.ingressClassName: nginx and using Traefik supported NGINX annotations, for example nginx.ingress.kubernetes.io/use-regex.
    See an example bellow.
  3. Try to access the app using the ingress (curl http://whoami.localhost/foo/bar for the provided example). The answer is not the one expected.

Non working example using the nginx IngressClass:

apiVersion: v1
kind: Service
metadata:
  name: whoami
spec:
  ports:
    - port: 80
  selector:
    app: whoami
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: whoami
spec:
  replicas: 2
  selector:
    matchLabels:
      app: whoami
  template:
    metadata:
      labels:
        app: whoami
    spec:
      containers:
        - name: whoami
          image: traefik/whoami
          ports:
            - containerPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: whoami-nginx
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  ingressClassName: nginx
  rules:
  - host: whoami.localhost
    http:
      paths:
      - path: /foo/.*
        pathType: ImplementationSpecific
        backend:
          service:
            name: whoami
            port: 
              number: 80

Can you suggest a fix?

Change the IngressClass 'nginx' spec.controller to "k8s.io/ingress-nginx".

Are you interested in contributing with a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions