What You Will Learn
Intermediate
- What Ingress is and how it works
- Routing by domain and path
- TLS/SSL termination
Ingress is an API object that manages external access to Services via HTTP. It provides name-based virtual hosting, path-based routing, and TLS termination.
ingress.yamlyaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ingress
spec:
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- host: web.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
tls:
- hosts:
- api.example.com
- web.example.com
secretName: tls-secretIngress vs LoadBalancer
LoadBalancer: 1 IP per Service (expensive). Ingress: 1 IP for ALL Services, routes by domain/path (cheap). Use Ingress for web apps, LoadBalancer for TCP/UDP.Ingress Controllers
Ingress needs a controller to actually route traffic. Popular options:
- NGINX Ingress Controller (most popular)
- Traefik (lightweight, modern)
- HAProxy Ingress
- Cloud provider controllers (GCE, AWS ALB)
Terminalbash
# Enable Ingress on minikube
minikube addons enable ingress
# Apply your Ingress
kubectl apply -f ingress.yaml
# Check
kubectl get ingressPractical Exercise
Enable Ingress: minikube addons enable ingress
Create 2 Deployments with different labels
Create 2 Services
Create an Ingress routing to both
Add /etc/hosts entry and test
Key Takeaways
- Ingress: HTTP routing by domain and path.
- 1 IP for all Services (vs 1 IP per LoadBalancer).
- Supports TLS/SSL termination.
- Needs an Ingress Controller (NGINX, Traefik).
- Best for: web apps with multiple domains/paths.
Comments
Comments
Post a Comment