Ingress Controllers and Ingress Resources
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. It allows you to define routing rules without exposing each service directly using a LoadBalancer or NodePort.
Components:
- Ingress Resource: Defines routing rules and hosts/paths
- Ingress Controller: Implements the actual routing (e.g., NGINX, Traefik, HAProxy)
Example Ingress Resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: example.com
http:
paths:
- path: /app
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
Deploying an Ingress Controller:
You must install an Ingress Controller separately (e.g., using Helm):
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install nginx ingress-nginx/ingress-nginx
With Ingress, you can manage TLS, traffic routing, and access control centrally and declaratively.