Hailu Meng:
apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: Ingress
metadata:
name: minimal-ingress
annotations:
<http://nginx.ingress.kubernetes.io/rewrite-target|nginx.ingress.kubernetes.io/rewrite-target>: /
spec:
ingressClassName: nginx-example
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80
This is the example from the doc. You can see it’s configured as nginx-example for ingressClassName.
Vitor Jr.:
ingress class isn’t mandatory
Vitor Jr.:
We “kind” (again KIND) can compare with storage classes. They exist, aren’t mandatory for PV, for example.
Hailu Meng:
Thanks @Vitor Jr… Agree it’s not mandatory but there is a default ingressclass will be used if it’s not specified. As I understand ingressclass is the object which really ties ingress resource with ingress controller, otherwise ingress controller doesn’t know what rules it will get. But how can we find the default ingressclass defined in cluster?
Vitor Jr.:
It’s in the docs:
Default IngressClass
You can mark a particular IngressClass as default for your cluster. Setting the <http://ingressclass.kubernetes.io/is-default-class|ingressclass.kubernetes.io/is-default-class>
annotation to true
on an IngressClass resource will ensure that new Ingresses without an ingressClassName
field specified will be assigned this default IngressClass.
Vitor Jr.:
But, as I said before, ingress class isn’t mandatory and you can not use it:
There are some ingress controllers, that work without the definition of a default IngressClass
. For example, the Ingress-NGINX controller can be configured with a https://kubernetes.github.io/ingress-nginx/#what-is-the-flag-watch-ingress-without-class|flag --watch-ingress-without-class
.
Hailu Meng:
Okay, so nginx ingress controller actually doesn’t really need ingressclass to make it work. That explains it then. I’m doing INGRESS NETWORKING – 2 lab and don’t see any ingressclass defined in the cluster. This lab has nginx ingress controller deployed so that proves we don’t need ingressclass for this controller. I did play with ingressClassName in the yaml but it didn’t make any difference on my result.
Hailu Meng:
by the way, since there is no ingressclass defined in the cluster so you can’t mark any as default.
Hailu Meng:
root@controlplane:~# kubectl get ingress ingress -n app-space
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress nginx * 80 7m39s
Hailu Meng:
Curious: should ingress have an IP address here? I don’t understand why we have ADDRESS column, ingress is a resource containing bunch of forwarding rules, why it should have IP address? unless this ADDRESS doesn’t mean IP address?
Vitor Jr.:
Actually, I believe the lab you’re doing the real reason is the kubernetes version. Check if isn’t an older version. Classes were implemented after 1.19 if I’m not wrong
Vitor Jr.:
Before the IngressClass resource and ingressClassName
field were added in Kubernetes 1.18, Ingress classes were specified with a <http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>
annotation on the Ingress. This annotation was never formally defined, but was widely supported by Ingress controllers.
Hailu Meng:
The lab is 1.20.0. I used kubectl command to create the ingress resource. It populated the ingressClassName in yaml for me when I specified class in the command.
Vitor Jr.:
About the empty address, it depends on how the ingress was implemented. For example, could be a LoadBalancer address:
Vitor Jr.:
But it can also take some time:
Hailu Meng:
The odd part is even the address is empty, the lab works. Something magic happens? It seems I still haven’t mastered these concepts.