Skip to content
tezvyn:
Menu

Kubernetes Ingress: The Cluster's Front Door

Source: kubernetes.ioMediumHow cards are made

Kubernetes Ingress: The Cluster's Front Door

Kubernetes Ingress is the smart receptionist for your cluster. It routes external HTTP/S requests to internal services based on hostnames or paths, letting you expose multiple apps under one IP.

Why it exists

Before Ingress, exposing a service meant creating a Service of type LoadBalancer. This provisions a separate, often expensive, cloud load balancer for every service you want to make public. This becomes costly and complex. Ingress was created to provide a single, consolidated, and intelligent entry point for multiple services.

The mental model

Ingress is like an apartment building's front desk. Instead of every apartment having its own external door, visitors arrive at one main entrance. They tell the receptionist which apartment they want (e.g., api.myapp.com/users), and the receptionist directs them to the right internal elevator (the corresponding Kubernetes Service). The Ingress resource is the list of instructions for the receptionist; the Ingress controller is the receptionist actually doing the work.

How it works

You define an Ingress resource in YAML, specifying rules for routing traffic based on the requested host (e.g., billing.example.com) or URL path (e.g., /api/v2). A separate application, the Ingress controller, runs in your cluster watching for these resources. When a request hits the controller's external IP, the controller inspects it, finds a matching Ingress rule, and forwards the traffic to the correct backend Service. The Ingress object is just configuration; the controller is the engine.

When to use it

Use Ingress whenever you need to expose one or more HTTP or HTTPS services. It's ideal for host-based virtual hosting (routing service-a.com and service-b.com from the same IP), path-based routing (routing /api and /ui to different services), and centralizing TLS/SSL termination for your applications.

When not to use it

Ingress is specifically for HTTP/S traffic (Layer 7). It is not the right tool for exposing non-HTTP protocols like a raw database connection or a game server's UDP stream. For those, you would still use a Service of type LoadBalancer or NodePort. For a very simple cluster with only one service to expose, a LoadBalancer Service can be simpler.

One canonical example

A common setup is routing traffic for a single domain to different microservices. An Ingress resource could have a rule that sends all requests for myapp.com/api to the api-backend service, while sending requests for myapp.com/ to the frontend-webapp service. Both services are exposed through the single IP address of the Ingress controller, which also handles the TLS certificate for myapp.com.

Interview question

To expose multiple HTTP/S applications via unique hostnames through a single public IP, centralizing TLS, which Kubernetes resource is most suitable?

  • a.A ClusterIP Service with a custom reverse proxy deployed as a Pod.
  • b.An Ingress resource.Correct
  • c.A separate Service of type LoadBalancer for each microservice.
  • d.A Service of type NodePort combined with an external DNS provider.
Why?

The correct answer is B because Ingress is specifically designed to provide a single, consolidated entry point for multiple HTTP/S services, enabling host-based routing and centralized TLS termination through one external IP. Option C, while exposing services, would provision a separate, often expensive, load balancer for each service, which Ingress aims to avoid.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles