Clarification on IngressClass Specification for Ingress Resources

Hi everyone,

I am a bit confused about the ingress.spec.ingressClassName concept in the Ingress resource, and I have a few questions that I need clarification on before my CKA exam:

  1. Is ingressClassName Spec Required in Ingress Resource?:
When writing a YAML for an Ingress resource, is the ingressClassName specification required? Or will Kubernetes automatically detect the correct Ingress controller without needing to specify it in the Ingress YAML?
  1. IngressClass for Deployed Ingress Controller:
If the ingressClassName is required, do we need to find the ingressClass created for the deployed Ingress controller and mention it explicitly in the Ingress resource? Or is it assumed that the appropriate class will be used by default?

  1. Creating an IngressClass for the Controller in the Exam:
In the CKA exam, if the IngressClass doesn't already exist, are we expected to create one for the controller and mention it in the Ingress resource YAML, or should we rely on default settings if applicable?

  1. It depends :slight_smile: . If there is more than one ingress controller in the cluster (there won’t be in the exam), then definitely.
  2. You can usually find the ingress class name as a command line argument to the controller. Examine the controller deployment with -o yaml
  3. No, you won’t.

Now if you look at the Ingress Networking 2 lab where you are walked through the deployment of ingress-nginx, then create an ingress, you’ll notice that

  • kubectl get ingressclasses -A shows no classes defined in the cluster.
  • When you deploy the ingress resource, ingressClassName is not specified, yet it still works.

So this means that if there is only one ingress controller, and no IngressClass resource defined, the controller will accept all Ingress resources.

1 Like

Hi,

@Alistair_KodeKloud

Thank you for the clarification; I understand now