Skip to main content

What is Ingress Class Name in Kubernetes?

β€” Aswin

If you're new to Kubernetes and Ingress resources, understanding what an Ingress class name is and how it works can help you manage your application's traffic more effectively.

What is an Ingress?

Before diving into Ingress Class Names, let's quickly recap what Ingress is in Kubernetes.

An Ingress is an API object that manages external access to services in a cluster, typically HTTP(S). It acts as a gateway for incoming traffic and provides load balancing, SSL termination, and name-based virtual hosting.

An Ingress controller is the actual component that watches for Ingress resources and implements the rules defined in them to manage external access to services in the cluster. Examples include Nginx, Traefik, and HAProxy.

What is Ingress Class?

An Ingress Class is a way to define and manage different types of Ingress controllers within a cluster.

It allows you to specify which Ingress controller should handle a given Ingress resource, providing a method to differentiate and route traffic according to specific needs.

For example, you may be running an Nginx controller and an HAProxy-based controller in the same cluster. The following image shows the use of ingress class names and how it relates to the ingress objects.

Ingress Class Explained

An Ingress Class is defined as a Kubernetes ingress resource. It specifies the controller that will handle Ingress resources with a matching class name.

For example,

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: platform-ingress-class
spec:
  controller: k8s.io/platform-ingress-nginx

In this example, platform-ingress-class is an Ingress Class that specifies an Ingress controller with the identifier k8s.io/platform-ingress-nginx. You can get the controller names form the controller installation.

Now, when you create an ingress resource, you can mention the ingress class name using ingressClassName parameter so that the specific ingress controller will be used for routing.

For example,

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
spec:
  ingressClassName: platform-ingress-class
  rules:
    - host: argocd.techiescamp.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: argocd-service
                port:
                  number: 80

Real-World Example: Using Different Ingress Classes

In a Kubernetes cluster, you might have various applications and services, each with its own traffic management requirements. To illustrate the need for different Ingress classes, let’s consider a real-world scenario involving different types of applications and tools running in the cluster.

Scenario Overview

Imagine you have a Kubernetes cluster running the following:

  1. Platform Tools: Argo CD, Jenkins, Prometheus
  2. Normal Applications: Web apps, APIs
  3. Compliance-Required Applications: Applications with strict compliance and security requirements. For example payment apps.

To manage traffic effectively for each type of service, you use different Ingress controllers, each associated with a specific Ingress class.

Ingress Class Name Real-World Example

Conclusion

Ingress Classes in Kubernetes provide a flexible way to manage multiple Ingress controllers within a cluster.

By associating different Ingress resources with different Ingress classes, you can manage traffic management to meet various needs, whether for general applications, platform tools, or compliance-sensitive services.