Skip to main content
In this lesson we explain Kubernetes Ingress: what it is, how it differs from Services, and when to use it. You’ll learn how Ingress provides Layer 7 (HTTP/HTTPS) routing, TLS termination, and host/path-based traffic routing inside a Kubernetes cluster.

Scenario: Why Ingress?

Imagine you deploy an online store at myonlinestore.com:
  • Your storefront is built into a Docker image and deployed as a Deployment.
  • MySQL runs as a Pod and is exposed internally via a ClusterIP Service (mysql-service) so your app can access the database.
  • The storefront app is exposed using a NodePort Service (wear-service) which assigns a high port (e.g., 30080) on every node.
With a NodePort, users access the app via:
  • http://<node-ip>:30080
As traffic grows you scale pods and rely on Service-level load balancing. In production, though, you usually need:
  • Friendly hostnames (DNS pointing to an external IP rather than node IPs).
  • Standard ports (80/443), not high NodePort numbers.
  • Path- or host-based routing for multiple applications (e.g., /watch or watch.myonlinestore.com).
  • Centralized TLS termination and certificate management.
On public clouds, a Service of type LoadBalancer provisions a cloud load balancer (and still uses a NodePort under the hood). But if every Service required its own cloud load balancer, costs and complexity would grow quickly. Instead, you want a single HTTP(S) entrypoint that routes to multiple Services and handles TLS — that’s what Ingress provides.
A network architecture diagram for my-online-store.com showing HTTPS traffic routed through a top-level load balancer to two GCP load-balancers. Each GCP balancer forwards to a Kubernetes LoadBalancer service—wear-service (port 30080) with wear pods, and video-service (port 30082) with video pods.
Ingress gives you a single place to:
  • Route traffic by hostnames and URL paths (e.g., /apparel → apparel service, /video → video service).
  • Terminate TLS and centralize certificate handling.
  • Avoid provisioning a cloud load balancer for every Service.
Important: Ingress defines the desired HTTP(S) routing rules; an Ingress controller implements those rules by configuring an actual reverse proxy.
An Ingress resource is a declarative set of HTTP(S) routing rules. The Ingress controller (NGINX, Traefik, GCE, etc.) watches those resources and configures the underlying proxy to enforce routing and TLS.
Kubernetes does not include an Ingress controller by default. You must deploy one (NGINX, Traefik, cloud provider controller, etc.) before Ingress resources will be enforced.

How Ingress works — components and flow

  1. Deploy an Ingress controller (a Deployment/DaemonSet running NGINX, Traefik, Contour, HAProxy, etc.).
  2. Create Ingress resources (Kubernetes objects) describing host/path → Service mappings and TLS configuration.
  3. The controller watches the API for Ingress objects and updates its proxy configuration accordingly (routing, load balancing, TLS termination, rewrites, etc.).
  4. Expose the controller externally (Service type LoadBalancer or NodePort). That external exposure is typically a one-time setup; adding routes or certificates is handled by updating Ingress resources.

Ingress controller typical components

  • Deployment (or DaemonSet) running controller pods.
  • Service exposing the controller (NodePort or LoadBalancer) to receive external traffic.
  • Optional ConfigMap for controller-specific settings.
  • ServiceAccount + RBAC so the controller can watch Ingress, Services, Endpoints, Secrets, Pods, etc.
Common controllers: GCE (GCP Layer 7), NGINX, Contour, HAProxy, Traefik, Istio. NGINX is commonly used for examples and labs.

Simplified example: NGINX Ingress controller manifest

This is a minimal example showing the Deployment, ConfigMap, Service (NodePort), and ServiceAccount:
You should also apply the RBAC Role/ClusterRole and RoleBinding/ClusterRoleBinding so the controller can access required resources (Ingress, Services, Endpoints, Pods, Secrets).

Ingress resources: rules and examples

An Ingress resource defines how to route HTTP(S) traffic. The Ingress controller translates those rules into proxy configuration. Three common patterns:
  1. Default backend — route all traffic to a single Service.
  2. Path-based routing — same host, route different URL paths to different Services.
  3. Host-based routing — route by host header (subdomains) to different Services.

Example 1 — Default backend

Use a default backend when all incoming requests should go to one Service.
Create it:
Note: If a request doesn’t match any rules or hosts, it goes to the Ingress default backend. Many setups provide a small default-http-backend Service that returns a friendly 404 page.

Example 2 — Path-based routing

Route different URL paths on the same host to multiple backends.
Inspect the created Ingress:
An infographic titled "Ingress Resource – Rules" showing three columns for different subdomains (wear, watch, and "everything else") with example URLs and boxed path rules illustrating how requests are routed (e.g., /returns, /movies, /tv). Each column contains sample images inside rule boxes to represent the different paths.

Example 3 — Host-based routing

Route traffic using the Host header (subdomains).
Host-based routing is useful when you want separate subdomains for different applications (e.g., wear. vs watch.). Path-based routing is useful when a single host serves multiple apps under different paths.
An infographic titled "Ingress Resource" showing three vertical cards for www.my-online-store.com/wear, /watch, and /eat or /listen. The left card displays clothing photos, the center shows people watching a live stream on a laptop, and the right shows a colorful "Oops!! 404" placeholder.

Comparison: routing approaches

TLS / HTTPS with Ingress

  • Ingress supports TLS termination. Create a Kubernetes Secret of type kubernetes.io/tls containing your certificate and private key, then reference that secret in the Ingress tls section.
  • TLS can be applied per-host (recommended) or globally, depending on the controller’s capability.
  • Use certificate automation tools like cert-manager to obtain and renew certificates from Let’s Encrypt automatically.
Example TLS snippet (inside an Ingress spec):

Best practices and notes

  • Deploy a single Ingress controller (or a controller per team/namespace if needed) and expose it externally once (LoadBalancer or NodePort). Then manage routing via Ingress resources.
  • Keep certificate secrets secure (RBAC and namespace scoping).
  • Use pathType Prefix or Exact depending on desired behavior. Check controller docs for regex or advanced matching options.
  • Test Ingress behavior with kubectl describe ingress and controller logs when troubleshooting.

Summary

  • Ingress is the Kubernetes-native way to provide HTTP/HTTPS routing and TLS termination at Layer 7.
  • You must deploy an Ingress controller (NGINX, Traefik, cloud controller, etc.) to implement Ingress resources.
  • Choose default, path-based, or host-based routing based on your application topology.
  • Expose the controller externally once, then add routes and TLS via Kubernetes manifests.

Practice labs

  • Lab type 1: Ingress controller, Ingress resources, and apps are pre-deployed. Explore the cluster, inspect resources, and answer scenario-driven questions.
  • Lab type 2: Deploy an Ingress controller and create Ingress resources from scratch; configure TLS and test routing.
Good luck with the labs — enjoy practicing Ingress!

Watch Video