What is Kubernetes Ingress?

· Category: Kubernetes

Short answer

Kubernetes Ingress is an API object that manages external access to services, typically HTTP and HTTPS. It provides routing rules, SSL termination, and load balancing, but requires an Ingress controller to function.

How it works

You define an Ingress resource with rules that map hostnames and paths to backend services. An Ingress controller, such as NGINX or Traefik, watches these resources and configures its underlying reverse proxy accordingly.

Example

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: myingress
spec:
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web
            port:
              number: 80

Why it matters

Ingress consolidates external access management, reducing the need for multiple LoadBalancer services. It supports path-based and host-based routing, SSL termination, and can integrate with cert-manager for automatic TLS certificates.

Key differences

  • Ingress: Layer 7 routing, requires a controller.
  • LoadBalancer: Layer 4, one per service, cloud-dependent.
  • NodePort: Direct node access, limited port range.

Common issues

  • Without an Ingress controller, Ingress resources have no effect.
  • Default backends handle unmatched routes.
  • PathType Prefix vs Exact behavior can be confusing.