Kubernetes Ingress

Route HTTP and HTTPS traffic into your cluster with Ingress rules, controllers, TLS termination, and host or path based routing.

What Is Ingress?

An Ingress is a Kubernetes API resource for HTTP and HTTPS routing. It does not handle traffic by itself. An Ingress Controller such as NGINX or Traefik watches Ingress resources and implements the routing behavior.

Why Use Ingress?

Ingress lets you:

  • route by host name
  • route by URL path
  • terminate TLS centrally
  • share one public entry point across many services

Ingress vs LoadBalancer Service

TopicIngressLoadBalancer Service
Routing levelLayer 7 HTTP/HTTPSLayer 4 network exposure
Multiple appsGreat fitOften one LB per Service
TLS terminationCommon featurePossible but less centralized
Path routingYesNo native path rules

Traffic Diagram

Internet → Ingress Controller → Services → Pods

Internet

app.example.com

HTTP/HTTPS

Ingress Controller

NGINX / Traefik

/api → api-service:80

/web → web-service:80

routes by path/host

Service

api-service

api-pod-1, api-pod-2

Service

web-service

web-pod-1, web-pod-2

Path-Based Routing Example

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

Host-Based Routing Example

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

TLS Termination Example

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

Why the Controller Matters

Without an Ingress Controller, the Ingress resource is only a rule definition. The controller is the actual traffic manager.

Think of Ingress as the route map and the Ingress Controller as the traffic police who enforce it.

Exercise

Controller Need

Why is an Ingress Controller required?

Exercise

Path Routing

Which Kubernetes resource is best suited for routing `/api` to one service and `/` to another over HTTP?

Continue Learning

Explore Related Topics

Try the Tool

Related Resources