In this lesson, you will learn how the Kubernetes Ingress resource and controller act as an intelligent gateway to route external HTTP traffic to your cluster services.
The Dual-Component Design
In Kubernetes, external access to services is often handled by NodePort or LoadBalancer types. However, these are rigid and often inefficient for large applications. Ingress solves this by decoupling traffic routing rules from the underlying infrastructure.
The architecture relies on two distinct pieces working in tandem:
- The Ingress Resource: A declarative API object that contains your routing rules (e.g., "send traffic for
api.example.comto thebackend-service"). It does nothing on its own; it simply stores the configuration in the cluster's state. - The Ingress Controller: A specialized process (like NGINX, Traefik, or HAProxy) running as a Pod inside your cluster. It constantly watches the API server for changes to Ingress resources. When it detects a new rule, it dynamically updates its internal load balancer configuration to reflect those paths.
How It Works in Practice
Think of the Ingress resource as a "blueprint" and the Controller as the "construction crew." When you define a rule, the controller interprets it and applies it to its proxy configuration:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web-ingress
spec:
rules:
- host: myapp.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: backend-service
port:
number: 8080
Without the controller, the YAML above is just data stored in etcd. The controller reads this, automatically configures its proxy to listen for myapp.com/api, and forwards that traffic to the correct Pods behind backend-service. This allows you to expose multiple services under a single IP address, handle SSL/TLS termination centrally, and perform host-based routing without needing a dedicated LoadBalancer service for every single app.
By separating the intent (the resource) from the implementation (the controller), Kubernetes allows you to swap out your networking proxy without changing your application manifests.
Key Takeaway: Ingress architecture separates routing policy from implementation, allowing an Ingress Controller to watch the Ingress resource and automatically manage complex HTTP traffic patterns at the cluster edge.