Ingress & Gateway API
Route HTTP traffic by host and path with Ingress and HTTPRoute.
By Invicly Tech, , in Kubernetes Administrator (CKA). About 9 minutes to read.
In short
Ingress routes external HTTP and HTTPS traffic to Services by host and path, but only works with an Ingress controller installed. Gateway API is the newer, role-oriented successor with GatewayClass, Gateway and HTTPRoute objects. Both terminate TLS and forward to ordinary Services.
Explained simply
A LoadBalancer Service per app gets expensive and messy: ten apps, ten public IPs. Most web traffic is HTTP, so it is easier to have one smart entry point that reads each request and sends it to the right Service, based on the host name or the URL path.
Kubernetes has two APIs for that entry point. Ingress is the older, simple one: a list of host and path rules. Gateway API is the newer one, split into objects for different people: platform teams own the Gateway, app teams own their routes.
Neither API does anything alone. They are just descriptions. A controller (a proxy such as NGINX, HAProxy, Traefik, Envoy or Cilium) reads them and actually handles the traffic. No controller means no traffic, even if the YAML looks perfect.
Both can also handle HTTPS. You store the certificate and key in a TLS Secret, point the Ingress or Gateway at it, and the proxy decrypts traffic before passing it to your app.
Press Play on a diagram to walk through it one step at a time.
- GatewayClass
- Infrastructure provider
- Names the controller
- Gateway
- Cluster operator
- Listeners: ports, TLS
- HTTPRoute
- App developer
- Hosts, paths, backendRefs
- Ingress (older API)
- ingressClassName
- rules and tls
- Step 1Client
GET https://shop.example.com/cart.
- Step 2Controller or Gateway
Terminates TLS, matches host and path.
- Step 3Service
Route forwards to backend Service and port.
- Step 4Pods
Ready endpoints serve the response.
- One object holds everything
- HTTP and HTTPS only
- Extras via controller annotations
- Built into Kubernetes
- API frozen, still supported
- Split by role: class, gateway, route
- HTTP, gRPC, TLS and more route types
- Headers, weights, redirects in the spec
- CRDs installed separately
- Where new features land
In depth
Ingress rules, path types and classes
Each Ingress rule has an optional host and a list of paths, each pointing to a Service name and port. pathType Exact matches only that path. Prefix matches by path segments: /shop matches /shop and /shop/cart but not /shopping. ImplementationSpecific leaves it to the controller. When several paths match, the longest wins.
spec.ingressClassName picks the controller. If it is missing, the IngressClass marked with the annotation ingressclass.kubernetes.io/is-default-class: "true" is used, and if there is no default, the Ingress may be ignored. Features like URL rewrites or rate limits are controller-specific annotations and do not carry over between controllers. The Ingress API itself is frozen: it still works, but new features only go into Gateway API.
- kubectl get ingressclass shows installed classes
- A rule with no host matches every host
- defaultBackend catches requests that match no rule
Installing a controller in practice
Controllers are installed like any app: with Helm or a manifest, usually as a Deployment plus a Service of type LoadBalancer or NodePort. On a lab cluster with no cloud load balancer, the controller's Service is often NodePort, so you test with curl -H "Host: shop.example.com" http://NODE_IP:NODEPORT/.
A note on choice: the community ingress-nginx controller was retired in March 2026 and gets no further releases, so new clusters should pick a maintained Ingress controller or move to Gateway API. On the exam, a controller is normally already installed; your job is to find its class name and write correct rules. kubectl describe ingress shows the address the controller assigned and the backends it resolved.
Gateway API objects and how they attach
Gateway API is a set of CRDs you install separately (the standard channel from the kubernetes-sigs/gateway-api releases), plus a controller. A GatewayClass names the controller through controllerName. A Gateway uses that class and defines listeners: each has a name, protocol (HTTP or HTTPS), port, optional hostname and, for HTTPS, tls mode Terminate with certificateRefs to a TLS Secret.
allowedRoutes on a listener decides which namespaces may attach routes: Same (the default), All, or a label Selector. An HTTPRoute attaches with parentRefs, optionally naming one listener with sectionName. Rules match on path (PathPrefix, Exact), headers, query parameters or method, can apply filters like RequestRedirect or URLRewrite, and list backendRefs. Giving two backendRefs weights such as 90 and 10 splits traffic, which is a simple canary release.
- Platform team to Gateway controller: Create GatewayClass and Gateway1Create GatewayClass and Gateway
- Gateway controller to Platform team: Gateway status: Accepted, Programmed, address2Gateway status: Accepted, Programmed, address
- App team to Gateway controller: Create HTTPRoute with parentRefs3Create HTTPRoute with parentRefs
- 4Check allowedRoutes and backendsGateway controller to Gateway controller: Check allowedRoutes and backends
- Gateway controller to App team: Route status: Accepted, ResolvedRefs5Route status: Accepted, ResolvedRefs
Debugging with status conditions
Gateway API objects report problems in their status, which makes them easier to debug than Ingress. A Gateway should show Accepted and Programmed True; if Programmed stays False, the controller could not create the proxy or get an address. An HTTPRoute shows a status entry per parent: Accepted False with reason NotAllowedByListeners means the listener's allowedRoutes rejects the route's namespace. ResolvedRefs False means a backend Service or port does not exist, or it lives in another namespace without a ReferenceGrant allowing the reference.
For Ingress, check in this order: is the controller running, does the class name match, does describe show the backend endpoints, and does the TLS Secret exist in the same namespace as the Ingress.
- kubectl get gateway,httproute -A
- kubectl describe httproute NAME, then read Status > Parents > Conditions
- Cross-namespace backendRefs need a ReferenceGrant in the target namespace
Learn it in 4 short steps
About 1h each. Track them with a timer in your plan.
- 1Install an Ingress controller~1h
- 2Route by host and path with Ingress~1h
- 3Add TLS to an Ingress~1h
- 4Create a Gateway and HTTPRoute~1h
Key points
- An Ingress without a running controller does nothing.
- pathType must be Prefix, Exact or ImplementationSpecific.
- TLS uses a kubernetes.io/tls Secret in the same namespace as the Ingress.
- HTTPRoute attaches to a Gateway through parentRefs.
- The Ingress API is frozen; new features go into Gateway API.
Key terms
Tap a card to flip it. 0/5 known
Examples
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: shop, namespace: web }
spec:
parentRefs: [{ name: main-gw, namespace: infra }]
hostnames: ["shop.example.com"]
rules:
- matches: [{ path: { type: PathPrefix, value: /cart } }]
backendRefs: [{ name: cart-svc, port: 80 }]
- backendRefs: [{ name: web-svc, port: 80 }]Route /cart to one Service and everything else to another.
Host and path routing with TLS on Ingress
Requirement: shop.example.com/ goes to web, shop.example.com/api goes to api, over HTTPS. Step 1: create the TLS Secret in the app's namespace. Step 2: create the Ingress imperatively; a trailing * makes a Prefix path, and tls= adds the certificate. Step 3: describe it to see resolved backends. Step 4: test with curl, forcing the host name to the controller's address.
kubectl -n shop create secret tls shop-tls --cert=shop.crt --key=shop.key
kubectl -n shop create ingress shop --class=nginx \
--rule="shop.example.com/*=web:80,tls=shop-tls" \
--rule="shop.example.com/api*=api:8080,tls=shop-tls"
kubectl -n shop describe ingress shop
curl -k --resolve shop.example.com:443:CONTROLLER_IP https://shop.example.com/apiA canary release with HTTPRoute weights
You want 10 percent of traffic on the new version. Step 1: run two Deployments with Services web-v1 and web-v2. Step 2: write an HTTPRoute attached to the shared Gateway with two weighted backendRefs. Step 3: check the route status is Accepted and ResolvedRefs. Step 4: raise the weight in steps until v2 takes 100.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: web, namespace: web }
spec:
parentRefs: [{ name: main-gw, namespace: infra, sectionName: https }]
hostnames: ["www.example.com"]
rules:
- backendRefs:
- { name: web-v1, port: 80, weight: 90 }
- { name: web-v2, port: 80, weight: 10 }Quick reference
- kubectl create ingress NAME --class=C --rule="host/path*=svc:port,tls=secret"
- pathType Prefix matches whole path segments: /shop matches /shop/cart, not /shopping
- Default class annotation: ingressclass.kubernetes.io/is-default-class: "true"
- TLS Secret type kubernetes.io/tls, same namespace as the Ingress
- HTTPRoute attaches with parentRefs; sectionName picks one listener
- Listener allowedRoutes.namespaces.from: Same (default), All or Selector
- Healthy Gateway: Accepted and Programmed True; healthy route: Accepted and ResolvedRefs True
Common mistakes
- Omitting ingressClassName when no default IngressClass exists.
- Pointing a route at a Service port that does not exist.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
List the installed IngressClasses and say which one is the default.
- Exercise 2medium
Create an Ingress app in namespace web: host app.example.com, path /v1 (Prefix) to Service v1:80 and path /v2 to Service v2:80, class nginx.
- Exercise 3hard
Create a Gateway gw in namespace infra (class given as cls) with an HTTP listener on port 80 accepting routes from all namespaces, and an HTTPRoute in web sending app.example.com to Service app:80.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is Ingress deprecated?
- The Ingress API is not deprecated, but it is frozen: no new features. Gateway API is the recommended path for new work, and some popular Ingress controllers have been retired.
- Why does my Ingress have no ADDRESS?
- Usually no controller handles it: none is installed, or ingressClassName does not match an installed class. Check kubectl get ingressclass and the controller Pods.
- Do I need a LoadBalancer Service with an Ingress?
- The controller itself needs a way in, typically one LoadBalancer or NodePort Service. Your app Services behind it can stay ClusterIP.