Kubernetes ingress
How a request from the internet finds the right service inside a cluster: one public door, rules by host and path, the proxy that enforces them, and where HTTPS ends.
In 30 seconds
Services in a Kubernetes cluster are reachable only from inside it. An ingress is the way in for web traffic: one public address in front of many services.
It is a list of rules. Each rule says: requests for this host name, and this path, go to that service.
The rules do nothing alone. An ingress controller, a proxy running in the cluster, reads them and forwards each request. It usually also handles HTTPS, decrypting at the door: TLS termination.
Kubernetes ingress, step by step
Simplified: a cloud load balancer usually sits in front of the controller, and traffic inside can be encrypted again. Kubernetes’ newer Gateway API does the same job with more features.
- Step 1: Services stay inside. A cluster runs three services: a shop front (web), its API and a blog. Each has a stable address, but those addresses only mean something inside the cluster. A browser out on the internet has no route to 10.96.0.20, so as things stand nobody outside can use any of them.
- Step 2: One door for HTTP. You could give every service its own public load balancer, each with its own address and its own cost. An ingress takes the other route: one entry point for web traffic, on one public address, that can reach every service inside. The door is a proxy called the ingress controller.
- Step 3: Rules by host. Both site names point at the same public address, so the controller needs another way to tell requests apart. Every HTTP request names the site it wants in its Host header. An ingress is a list of rules that maps hosts to services: blog.example.com to the blog service, shop.example.com to web.
- Step 4: Rules by path. Rules can also split one site by the path of the URL. On shop.example.com, anything starting with /api goes to the api service and everything else to web. When several paths match, the longest one wins, so /api/cart is sent to api even though it also starts with /.
- Step 5: The ingress controller. The ingress itself is only a list stored in the cluster; it moves no traffic. The work is done by an ingress controller, a reverse proxy such as NGINX, Traefik or HAProxy running in pods of its own. It watches the rules, reconfigures itself when they change, and forwards each request. No controller, no effect.
- Step 6: TLS termination. Browsers speak HTTPS, so the request arrives encrypted and its path cannot be read. The controller holds the site’s certificate and private key, completes the TLS handshake and decrypts. Now it can see the path, apply the rules and pass the request on. The encryption ends, or terminates, at the door.
- Step 7: A request, end to end. Put together: DNS turns shop.example.com into the one public address. The controller ends the TLS connection there, reads host and path, and finds the matching rule. It forwards the request to the api service, which hands it to one of its pods. The reply returns the same way, encrypted again at the door.
Try it yourself
Learn this first
- Kubernetes pods, deployments and servicesPods run the app, a deployment keeps them alive, a service gives them one address. Intermediate
- HTTPSHTTP wrapped in TLS: what the padlock hides, what it proves and what still leaks. Beginner
- Load balancersOne address, many servers: how requests are shared out and dead servers skipped. Beginner
Learn next
- API gatewaysOne front door for many services: routing, shared checks, and the risk that comes with it. Intermediate
- Digital certificates and certificate authoritiesHow a signed file and a chain of authorities tie a public key to a name. Intermediate
- GitOpsA Git repository says what should run; an agent keeps the cluster matching it. Intermediate
Spotted a mistake on this page?