Ingress & Ingress Controllers

Difficulty: Advanced

Question

What is an Ingress in Kubernetes, how does an Ingress controller work, and how does it differ from exposing a service with type LoadBalancer?

Answer

An Ingress is a Kubernetes object that defines Layer 7 (HTTP/HTTPS) routing rules, such as "send api.shop.in/orders to the orders Service", and an Ingress controller is the reverse proxy (NGINX, Traefik, HAProxy, a cloud ALB) that reads those rules and enforces them. A LoadBalancer Service works at Layer 4 and gives one service its own external IP, while a single Ingress can route many hostnames and paths to many services behind one load balancer.

How Ingress actually works

  1. You install an Ingress controller. It usually runs as a Deployment exposed by one LoadBalancer Service.
  2. You create Ingress objects with host and path rules, each pointing to a ClusterIP Service.
  3. The controller watches the API server for Ingress, Service and EndpointSlice changes and regenerates its proxy config.
  4. A request hits the cloud LB, reaches the controller, gets matched by host and path, has TLS terminated, and is proxied to a Pod.

An Ingress object on its own does nothing. Without a controller in the cluster, nothing listens. The ingressClassName field picks which controller handles a given Ingress when you run more than one.

Ingress vs LoadBalancer Service

AspectLoadBalancer ServiceIngress
OSI layerL4 (TCP/UDP)L7 (HTTP/HTTPS)
RoutingOne IP per serviceHost and path based, many services
TLSPassed through or handled by cloud LBTerminated at the controller using a Secret
CostOne cloud LB per serviceOne LB shared by all routes
ProtocolsAny TCP/UDPMainly HTTP; TCP/UDP only via controller-specific hacks

For an e-commerce platform with shop.in, api.shop.in and admin.shop.in backed by ten services, Ingress needs one load balancer; LoadBalancer Services would need ten.

Features you get at the edge

  • TLS termination using a kubernetes.io/tls Secret, often issued automatically by cert-manager with Let's Encrypt.
  • Path rewrites, redirects, rate limiting, auth, CORS and canary routing, mostly via controller-specific annotations (for example nginx.ingress.kubernetes.io/rewrite-target).
  • Path types: Prefix, Exact and ImplementationSpecific.

The 2026 picture: Gateway API and ingress-nginx retirement

The Ingress API is stable but frozen. Its successor is the Gateway API (GA since late 2023), which splits responsibilities into GatewayClass, Gateway and HTTPRoute, and supports header matching, traffic splitting and TCP/gRPC routes as first-class fields instead of annotations. The community ingress-nginx project announced its retirement, with best-effort maintenance ending in March 2026, so new clusters are moving to Gateway API implementations (Envoy Gateway, Istio, Cilium, NGINX Gateway Fabric) or to other maintained controllers. Mentioning this in an interview shows you are current.

Common mistakes

  • Forgetting to install a controller or set ingressClassName, then wondering why the Ingress has no address.
  • Pointing a rule at a Service port that does not exist.
  • Relying heavily on annotations, which lock you into one controller.
Request path through an Ingress. One cloud load balancer fronts many services through host and path rules.
  1. Client: Calls https://api.shop.in/orders.
  2. Cloud load balancer: The single LoadBalancer Service for the controller.
  3. Ingress controller: Terminates TLS and matches host and path rules.
  4. ClusterIP Service: orders Service picks a Ready Pod.
  5. Pod: The orders container handles the request.

Code examples

Ingress with TLS and host/path routing

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: shop
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  ingressClassName: nginx            # which controller handles this
  tls:
    - hosts: [api.shop.in]
      secretName: api-shop-tls       # cert-manager fills this Secret
  rules:
    - host: api.shop.in
      http:
        paths:
          - path: /orders
            pathType: Prefix
            backend:
              service:
                name: orders
                port:
                  number: 80
          - path: /payments
            pathType: Prefix
            backend:
              service:
                name: payments
                port:
                  number: 80

Both services stay ClusterIP. The controller terminates TLS for api.shop.in and routes by path.

Equivalent Gateway API HTTPRoute

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: orders
spec:
  parentRefs:
    - name: public-gateway           # Gateway owned by the platform team
  hostnames: ["api.shop.in"]
  rules:
    - matches:
        - path: { type: PathPrefix, value: /orders }
      backendRefs:
        - name: orders
          port: 80

Gateway API separates the shared Gateway (owned by platform or ops) from the routes that app teams own.

Key points

  • Ingress is L7 HTTP routing; a LoadBalancer Service is L4 and per service.
  • An Ingress needs an Ingress controller; the object alone does nothing.
  • One Ingress controller behind one LB can serve many hosts and paths, saving cost.
  • TLS is terminated at the controller using a TLS Secret, often managed by cert-manager.
  • Gateway API is the successor to Ingress; ingress-nginx is retired as of March 2026.

Common follow-up questions

  • How would you set up automatic HTTPS certificates for an Ingress?
  • What does the Gateway API improve over Ingress?
  • How would you do a canary release at the ingress layer?
  • How do you expose a non-HTTP service, like a TCP game server?

Interview tips

  • Draw the chain client to LB to controller to Service to Pod; it makes clear that Ingress still relies on a LoadBalancer underneath.
  • Mention cost and the one-LB-per-service problem as the practical reason Ingress exists.
  • Bringing up Gateway API and the ingress-nginx retirement signals you follow the ecosystem.

Concepts covered

Ingress, Ingress Controller, Gateway API, TLS Termination, Host and Path Routing

More Kubernetes & Orchestration questions