A Service of type LoadBalancer costs one cloud load balancer per service. An Ingress routes many hosts and paths through one.
flowchart LR
U[Users] --> LB[Cloud load balancer]
LB --> IC[Ingress controller]
IC --> A[Service web]
IC --> B[Service api]
An Ingress object is only a set of rules; an ingress controller (for example ingress-nginx) must be installed to act on them.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install ingress ingress-nginx/ingress-nginx -n ingress --create-namespace
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata: { name: site }
spec:
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service: { name: web, port: { number: 80 } }
Since 1.22 only the v1 API exists. Point DNS for app.example.com at the controller’s load balancer address.