I am setting up my ingress controller, ingress class and ingress to expose a service outside the cluster. This is fresh cluster setup.
I have setup the nginx-ingress controller using
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.41.0/deploy/static/provider/baremetal/deploy.yaml
The next step based on my understanding is to create the ingress class https://v1-18.docs.kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class
apiVersion: networking.k8s.io/v1beta1
kind: IngressClass
metadata:
name: external-lb
spec:
controller: example.com/ingress-controller
parameters:
apiGroup: k8s.example.com/v1alpha
kind: IngressParameters
name: external-lb
How did they get the name of the controller example.com/ingress-controller
?
I have run multiple scenarios with IngressClass
, Ingress
and Nginx Ingress Controller
.
Scenario 1
--ingress-class
value which is nginx
Output: Response 404
Scenario 2
ingress-class
ingress-testOutput: Response 404
Scenario 3
test
name--ingress-class
with value test
test
in ingressClassNameOutput: Proper response
Senario 4
nginx
name--ingress-class
with value nginx
nginx
in ingressClassNameOutput: Proper response
Conclusion
First of all, please keep in mind that there are 3 types of Nginx
. Open Source Nginx Ingress Controller
, you are probably using it. Nginx Incorporaton
(nginx inc) and Nginx Incorporaton Plus
.
In one of the scenarios, when I have used spec.controller: nginx.org/ingress-controller
with Nginx Ingress Controller
with argument --ingress-class=nginx
, in Nginx Ingress Controller
pod you will see entry which is pointing to k8s.io/ingress-nginx
.
To reproduce this behavior, you will need to deploy IngressClass
with specific controller and then deploy nginx.
apiVersion: networking.k8s.io/v1beta1
kind: IngressClass
metadata:
name: nginx
spec:
controller: nginx.org/ingress-controller
After deploying Nginx Ingress Controller
, controller pod will be in CrashLoopBackOff
state. In logs you will find entry:
E1118 15:42:19.008911 8 main.go:134] Invalid IngressClass (Spec.Controller) value "nginx.org/ingress-controller". Should be "k8s.io/ingress-nginx"
It works only when IngressClass
name is set to nginx
.
I would say that nginx.org/ingress-controller
is for Nginx Incorporated
and k8s.io/ingress-nginx
for Open Source Nginx Ingress
.
If custom value is used for --ingress-class
argument in the controller Deployment manifest
, presence or absence of IngressClass
object with the same name doesn't made any difference in, how the cluster works, if only you keep Ingress spec.ingressClass
value the same with controller argument. Moreover, if it's present, IngressClass spec.controller
can have any value that match the required pattern "domain like" and that didn't affect Ingress
workflow behavior on my cluster at all.
In addition, Ingress
works fine if I put the correct value of the ingress-class
either to spec.ingressClass
property or to metadata.annotation.kubernetes.io/ingress.class
accordingly. It gives an error like the following if you try to put both values to the same Ingres object:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
ingressClassName: nginx
The Ingress "test-ingress" is invalid: annotations.kubernetes.io/ingress.class: Invalid value: "nginx": can not be set when the class field is also set
Please keep in mind it was tested only for Nginx Ingress Controlle. If you would like to use IngressClass
with other Ingress Controllers
like Traefik or Ambasador, you would check their release notes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With