Room 18
INGRESS CONTROLLERS
The Traffic Router
- Ingress is the smart HTTP gateway - routing requests based on hostname and path.
- Install an Ingress controller and route traffic to multiple backends.
📜 Mission Briefing
- Install the NGINX Ingress controller:
- Wait for the ingress controller to be ready.
- Apply
ingress.yaml- defines routing rules for two services. - The Ingress routes
/app1to service-a and/app2to service-b. - Test with curl using the Host header.
- The service-a returns the password
ingress77.
Key Commands
| Command | Purpose |
|---|---|
kubectl get ingress |
List Ingress resources |
kubectl describe ingress NAME |
Ingress rules |
kubectl get pods -n ingress-nginx |
Ingress controller pods |
kubectl get ingressclass |
Available Ingress classes |
How Ingress Works
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: app.example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- path: /web
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
- host: admin.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: admin-service
port:
number: 80
tls:
- hosts:
- app.example.com
secretName: app-tls
# Path types:
# Exact: /foo matches ONLY /foo
# Prefix: /foo matches /foo, /foo/, /foo/bar
# Ingress controller is NOT built-in - you must install one:
# Popular: nginx, traefik, HAProxy, istio, envoy
# Install nginx ingress for Kind
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
# Wait for it to be ready
kubectl wait --namespace ingress-nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=90s
# Test with curl
curl -H "Host: app.example.com" http://localhost/api
Hints
Hint 1
Install the ingress controller and wait:
Hint 3
The password is ingress77.