Kubernetes Ingress Explained for Beginners
Your cluster now runs three apps, a shop front end, an API and an admin panel, each behind a Service from lesson 11, and all three must be public over HTTPS. This lesson explains Kubernetes ingress: how one entrance sends each request to the right Service by host name and URL path, which program does the work, and where certificates fit.
Why one load balancer per app does not scale
A LoadBalancer Service from lesson 11 gets its own cloud load balancer. Three apps means three load balancers, three public IP addresses and, on most clouds, three charges on the bill.
They cannot share HTTP routing either. A Service spreads connections by IP address and port without reading the HTTP request, so it cannot send shop.example.com/api to one app and shop.example.com/ to another.
An Ingress, a set of HTTP routing rules shared by many Services, fixes both. In the diagram, notice that one cloud load balancer is left, feeding an ingress controller, the program that picks the Service for each request.
An Ingress holds the routing rules
An Ingress is a Kubernetes object that holds routing rules for HTTP and HTTPS traffic. Each rule names a host, the site name a request asks for, and a list of URL paths, each pointing at a Service and port. This file, shop-ingress.yaml, describes the routes in the diagram:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: shop
spec:
ingressClassName: traefik
rules:
- host: shop.example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80
- host: admin.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: admin
port:
number: 80
The host is compared with the Host header, the line in every HTTP request that names the site wanted, which lets one IP address serve many sites. A rule with no host matches every host.
pathType is required and says how path is compared. Exact matches only that path. Prefix matches it and anything below it, one path segment at a time: /api matches /api and /api/orders, but not /apiv2. ImplementationSpecific leaves matching to the controller.
When several paths match, the longest wins, and on a tie Exact beats Prefix, so /api/orders goes to api although / matches too. A request matching no rule goes to a default backend: the one in the Ingress's defaultBackend field, or else the controller's own, which usually answers 404 Not Found. In the flowchart, notice that rule order in the file does not matter.
The ingress controller does the routing
An Ingress alone does nothing; it is only a record in the API server. An ingress controller is a program that watches Ingress objects and carries out their rules. Unlike the controllers in kube-controller-manager from lesson 8, it does not run by default: you install one, though some managed clusters and distributions include one.
Most controllers are a reverse proxy, a server that receives requests on behalf of other servers and passes them on, reconfigured whenever an Ingress changes. Traefik, HAProxy Ingress and F5's NGINX Ingress Controller run as pods, usually behind one LoadBalancer Service. Cloud controllers, such as the AWS Load Balancer Controller, instead configure the cloud's own HTTP load balancer.
A cluster can run several controllers. Each comes with an IngressClass, a small object naming a controller, and an Ingress picks one with ingressClassName; without it, the cluster's default class applies. To list the classes:
kubectl get ingressclass
With Traefik installed, for example, you see its class; your age will differ:
NAME CONTROLLER PARAMETERS AGE
traefik traefik.io/ingress-controller <none> 5m
The CONTROLLER column names the program behind each class. If kubectl prints No resources found instead, no controller is installed and no Ingress will work. With one in place, create the Ingress and check it:
kubectl apply -f shop-ingress.yaml
kubectl get ingress shop
You should see a created line, then the hosts and, once the controller has taken the Ingress, its address. The address is illustrative:
ingress.networking.k8s.io/shop created
NAME CLASS HOSTS ADDRESS PORTS AGE
shop traefik shop.example.com,admin.example.com 203.0.113.10 80 1m
An ADDRESS that stays empty means no controller has published one: often ingressClassName names no installed class, or, as on kind, the controller's own LoadBalancer Service is pending. A file without pathType is rejected with pathType must be specified.
HTTPS: TLS termination with a Secret
TLS (Transport Layer Security) is the encryption behind HTTPS. It needs a certificate, a signed file proving a server may use a host name, and the matching private key. The controller does TLS termination: it decrypts HTTPS at the entrance and, by default, sends plain HTTP on to the pods.
Both live in a Secret, an object for sensitive data covered in lesson 13. A TLS Secret has the type kubernetes.io/tls and the keys tls.crt and tls.key. Given the two files from a certificate authority, an organisation that signs certificates, this creates one:
kubectl create secret tls shop-tls --cert=shop.crt --key=shop.key
You should see one confirmation line:
secret/shop-tls created
A wrong file name gives an error ending in no such file or directory, and a certificate and key that do not belong together are rejected too. Then add a tls block under spec, listing the hosts the certificate covers, and apply the file again:
tls:
- hosts:
- shop.example.com
secretName: shop-tls
Ingress offers TLS on port 443 only, and PORTS now shows 80, 443. The hosts here must match the rule's hosts. In the diagram, notice that the Secret is referenced only by name.
Certificates expire, and manual renewal is easy to forget. cert-manager, an open-source CNCF project, automates it. Add an annotation, a key-value note on an object for tools to read, such as cert-manager.io/cluster-issuer naming an issuer you set up. cert-manager then gets a certificate from that issuer, for example Let's Encrypt, stores it in the secretName Secret and renews it before it expires.
Where it is heading: the Gateway API
The Ingress API is frozen: stable, but getting no new features. Anything beyond host and path, such as matching a header or sending a share of traffic to a new version, needs annotations that differ between controllers.
The Gateway API is the successor the Kubernetes project recommends. A GatewayClass names the controller, a Gateway is the entrance with its ports and certificates, often run by a platform team, and an HTTPRoute holds one app's rules, which that app's team can manage. Header matching and traffic weighting are built in. You install its object types separately, usually with your chosen implementation.
Whichever you use, check that the controller is still maintained. The community ingress-nginx project announced its retirement in November 2025 and ended in March 2026, with no more releases or security fixes. Existing installs keep running, but new clusters should not adopt it. F5's NGINX Ingress Controller is a separate project.
Check yourself
An Ingress sends / to web and /api to api, both Prefix. Where does /apiv2/status go?
To web. Prefix compares whole path segments, so /api does not match /apiv2; only / matches.
You apply a valid Ingress, the Services and pods are healthy, but ADDRESS stays empty. What do you check first?
Whether a controller handles it: run kubectl get ingressclass and compare with ingressClassName. An Ingress is only rules, so without a controller for its class nothing serves them.
A browser opens https://shop.example.com/api through the Ingress with the tls block. Is the request still encrypted when it reaches the api pod?
Not by default. The controller terminates TLS with the certificate from shop-tls, then forwards plain HTTP inside the cluster.
Go deeper
- NGINX ingress controller – Deep dive with AWS EKS: installs a controller on a managed cluster and shows what it creates; it uses the retired community ingress-nginx, so read it for the mechanics, not as an install guide.
- Monitoring NGINX Ingress Controller using Open-source tools: what to watch once one controller carries all your web traffic; the ideas apply to other controllers too.