07 - Ingress & Ingress Controllers
Why this matters
Services alone don't give you host/path-based routing, TLS termination, or a single external entry point. Ingress does — and almost every real-world cluster runs one.
Read this first — Definitions & Explanations
Ingress
An API object that describes HTTP/HTTPS routing into the cluster (host/path rules → backend Services). It is not a server by itself.
Ingress Controller
The software that implements Ingress rules (NGINX, Traefik, HAProxy, cloud controllers). Without a controller, Ingress objects do nothing useful.
Typical flow
Internet → LoadBalancer/NodePort of controller → Ingress rules → Service → Pods
TLS on Ingress
Usually referenced via a Secret (tls.crt / tls.key). Termination often happens at the Ingress controller.
Path and host rules
- Host-based:
api.example.comvswww.example.com - Path-based:
/apivs/
IngressClass
Selects which controller should handle an Ingress when multiple controllers exist.
Official docs (read for detail)
- Ingress
- Ingress Controllers
- Gateway API (newer L7 routing model)
Key Concepts
- Ingress resource (the routing rules) vs Ingress controller (the thing that actually implements them — nginx-ingress, Traefik, ALB controller, etc.) — Ingress resources do nothing without a controller running
- Host-based vs path-based routing
- TLS termination at the ingress
IngressClass— which controller handles which Ingress- Gateway API — the newer, more expressive successor to Ingress (know it exists)
YouTube search terms
- "Kubernetes Ingress explained nginx ingress controller"
- "Kubernetes Ingress vs Gateway API"
- "Kubernetes TLS termination ingress"
Hands-on lab (on prod-sim)
minikube addons enable ingress -p prod-sim
kubectl get pods -n ingress-nginx
kubectl create deployment app1 --image=hashicorp/http-echo -- -text="app1"
kubectl create deployment app2 --image=hashicorp/http-echo -- -text="app2"
kubectl expose deployment app1 --port=5678
kubectl expose deployment app2 --port=5678
cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: demo-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: app1.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app1
port:
number: 5678
- host: app2.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app2
port:
number: 5678
EOF
# Route via /etc/hosts + minikube ip, or minikube tunnel for LoadBalancer-style access
minikube ip -p prod-sim
curl --resolve app1.local:80:$(minikube ip -p prod-sim) http://app1.local
curl --resolve app2.local:80:$(minikube ip -p prod-sim) http://app2.local
Common mistakes and how to avoid them
- Creating an Ingress with no controller installed. An Ingress is only a set of rules, and nothing enforces it without a controller such as NGINX. Install one and set
ingressClassName. - Choosing the wrong
pathType.Exactmatches only the exact path whilePrefixmatches by path segments. A mismatch shows up as unexpected 404s. - Pointing the Ingress at a Service with no ready endpoints. The controller finds the rule but has no backend, so clients get 502 or 503. Check
kubectl get endpoints. - Naming a backend port that does not exist. The Ingress backend must reference a port the Service actually exposes. A wrong port gives 502.
- Keeping the TLS Secret in another namespace. The Secret referenced in
spec.tlsmust live in the same namespace as the Ingress.
Quick answers
What is the difference between an Ingress and an Ingress controller?
An Ingress is an API object that declares routing rules for HTTP and HTTPS traffic. An Ingress controller, such as NGINX or Traefik, is the running software that reads those rules and routes the traffic. Without a controller, an Ingress does nothing.
Why does my Ingress return 502 or 503?
The controller matched a rule but found no healthy backend. Usually the Service has no ready endpoints, the Service port in the Ingress is wrong, or the Pods fail their readiness probe. Check kubectl get endpoints and the controller logs.
How do you add TLS to an Ingress?
Store the certificate and key in a kubernetes.io/tls Secret in the same namespace, then list it under spec.tls with the hostnames. A tool such as cert-manager can issue and renew the certificate automatically from Let's Encrypt.
Notes
(fill in your own words after watching + labbing)