Skip to content
Back to Deployment

Kubernetes Ingress

HTTP routing to services with TLS, host-based and path-based routing.

ContainersAdvanced

Why

Ingress exposes multiple services through one load balancer with host/path routing and TLS. Ingress controllers (nginx, traefik, istio) handle the actual routing.

Docker is used by 59% of professional developers per the Stack Overflow 2024 survey, and Kubernetes runs 60% of containerized workloads in production (CNCF 2024 survey). Container orchestration reduces deployment-related incidents by 35% through declarative rollouts.

When

Use Ingress for HTTP services in K8s. Avoid for TCP/UDP — use LoadBalancer service.

How

1. Controller — install nginx-ingress or traefik 2. Ingress — define rules for host + path 3. TLS — cert-manager for auto Let's Encrypt 4. Host — route by Host header 5. Path — route by URL path 6. Annotations — rewrite, redirect, cors 7. Default — default backend for unmatched

Example

# ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: myapp annotations: cert-manager.io/cluster-issuer: letsencrypt spec: tls: - hosts: [api.example.com, app.example.com] secretName: myapp-tls rules: - host: api.example.com http: { paths: [{ path: /, pathType: Prefix, backend: { service: { name: api, port: { number: 80 } } } }] } - host: app.example.com http: { paths: [{ path: /, pathType: Prefix, backend: { service: { name: web, port: { number: 80 } } } }] } # Install controller helm install nginx-ingress nginx-ingress/nginx-ingress kubectl apply -f ingress.yaml

Common Problems

  • ⚠No ingress controller — Ingress resource exists but nothing routes, install controller first
  • ⚠TLS not working — cert-manager not installed or issuer not configured
  • ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical

Best Practices

  • ✓Use cert-manager for TLS — automatic Let's Encrypt, no manual certs
  • ✓Use path-based routing for /api and / — one hostname, multiple services
  • ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit

FAQ