NGINX Ingress controller version: master/0.32.0
Kubernetes version (use kubectl version): 1.18/NA
What happened:
The Multiple Ingress Controllers documentation hasn't been updated with the new ingressClass specs.
https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/
/kind documentation
For other people stumbling upon this: the ingressclass.spec.controller field is a well-known, domain-prefixed value that is hard-coded into nginx-ingress. See here.
Here's an example ingressclass. note that the name must match --ingress-class flag in your deployment.
apiVersion: networking.k8s.io/v1beta1
kind: IngressClass
metadata:
# this name must match the --ingress-class flag
name: my-example-class
annotations:
# optional: flag this as default ingclass
ingressclass.kubernetes.io/is-default-class: "true"
spec:
controller: "k8s.io/ingress-nginx" # this is a hard-coded into nginx-ingress
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
By the way, it is still not clear how to configure IngressClass for multiple nginx controllers. I assume it should somehow be done with linking actual controller with spec.parameters section:
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: external-lb
spec:
controller: example.com/ingress-controller
parameters:
apiGroup: k8s.example.com
kind: IngressParameters
name: external-lb
But is there some more clear example? Linking nginx-ingress deployments didn't work for me:
---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: nginx-internal
spec:
controller: k8s.io/ingress-nginx
parameters:
apiGroup: apps
kind: Deployment
name: nginx-ingress-controller-internal
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: nginx-public
spec:
controller: k8s.io/ingress-nginx
parameters:
apiGroup: apps
kind: Deployment
name: nginx-ingress-controller-public
Looking for same clarification as @alexzerd
parameters:
apiGroup: apps
kind: Deployment
name: nginx-ingress-controller-public
parameters are not supported.
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: nginx-public
spec:
controller: k8s.io/ingress-nginx
How do you define for multiple ingresses/ingress classes? Pre-v19 I have an internal ingress and an external ingress with ingress classes nginx-internal and nginx-external respectively. With annotations this meant using kubernetes.io/ingress.class: nginx-internal and kubernetes.io/ingress.class: nginx-external
Does this simply translate to two IngressClass resources, one with metadata.name: nginx-internal and one with metadata.name: nginx-external both with spec.controller: k8s.io/ingress-nginx?
Hey @pinkfloydx33! yes, that's how it works. I have the exact same use-case. The metadata.name and --ingress-class flag in your ingress deployment must match, see https://github.com/kubernetes/ingress-nginx/issues/5593#issuecomment-647538272.
@moolen is the creation of the IngressClass supported in the nginx ingress helm chart ?
Most helpful comment
For other people stumbling upon this: the
ingressclass.spec.controllerfield is a well-known, domain-prefixed value that is hard-coded intonginx-ingress. See here.Here's an example ingressclass. note that the
namemust match--ingress-classflag in your deployment.