From point A to point B
Point A: you know how to expose a service with an external IP, but that service only understands IPs and ports. Point B: by the end of this chapter you'll be able to publish HTTP applications with Ingress and with Gateway API, route by path, header or method, terminate TLS, roll out a canary version, set up redirects and route gRPC, all with Cilium and without installing another controller.
Why a service isn't enough
A LoadBalancer service spreads traffic at layer 4: IP and port. It can't say "/catalog goes to one team and /cart to another", terminate HTTPS or send 10% of requests to a new version. For that you need a layer 7 proxy at the cluster's front door.
Kubernetes defines the Ingress resource, but doesn't implement it: you have to install a controller. With Cilium you don't. It uses the Envoy that already runs on every node (chapter 2), so you have no other component to install, upgrade and monitor.
Cilium Ingress
Cilium Ingress needs kube-proxy replacement (chapter 6) and a way to give an external IP to the service it creates. In kind we solve that with LB IPAM and layer 2 announcements, which answer ARP for that IP on the local network (you'll see them in depth in chapter 10):
# values-ingress.yaml · for the kind-no-kube-proxy.yaml from chapter 6
kubeProxyReplacement: true
k8sServiceHost: kind-control-plane
k8sServicePort: 6443
ingressController:
enabled: true # disabled by default
l2announcements:
enabled: true
The test application is two minimal services, catalog and cart, that reply with a fixed text:
for app in catalog cart; do
kubectl create deployment $app --image=hashicorp/http-echo -- /http-echo -text="hello from $app"
kubectl expose deployment $app --port=80 --target-port=5678
done
Now the Ingress. The key is ingressClassName: cilium:
# shop-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: shop
spec:
ingressClassName: cilium
rules:
- http:
paths:
- path: /catalog
pathType: Prefix
backend:
service:
name: catalog
port:
number: 80
- path: /cart
pathType: Prefix
backend:
service:
name: cart
port:
number: 80
The Ingress creates a LoadBalancer service that stays at <pending> until there's a pool. Give it one inside kind's Docker network, and announce it at layer 2:
# lb-l2.yaml
apiVersion: cilium.io/v2
kind: CiliumLoadBalancerIPPool
metadata:
name: kind-pool
spec:
blocks:
- start: 172.18.255.200
stop: 172.18.255.220
---
apiVersion: cilium.io/v2alpha1
kind: CiliumL2AnnouncementPolicy
metadata:
name: kind-l2
spec:
loadBalancerIPs: true
interfaces:
- eth0
nodeSelector:
matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
kubectl apply -f shop-ingress.yaml -f lb-l2.yaml
kubectl get ingress shop # ADDRESS: 172.18.255.200
INGRESS=$(kubectl get ingress shop -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
# From a container on the kind network (on Linux, also from your terminal)
docker run --rm --network kind nicolaka/netshoot curl -s http://$INGRESS/catalog
# hello from catalog
docker run --rm --network kind nicolaka/netshoot curl -s -o /dev/null -w "%{http_code}\n" http://$INGRESS/admin
# 404 · the path doesn't exist in the Ingress
CiliumEnvoyConfig objects and uses them to program the Envoy on every node. You can see them with kubectl get ciliumenvoyconfigs -A.Terminate TLS
For testing, generate a certificate with mkcert (in production, use cert-manager) and store it in a secret:
mkcert "*.thor.test"
kubectl create secret tls thor-test-cert \
--cert=_wildcard.thor.test.pem --key=_wildcard.thor.test-key.pem
# Add to the Ingress spec
tls:
- hosts:
- shop.thor.test
secretName: thor-test-cert
rules:
- host: shop.thor.test
http:
paths: … # the same paths as before
# --resolve points the name to the IP; --cacert trusts the mkcert CA without installing it
curl -s --resolve "shop.thor.test:443:$INGRESS" \
--cacert "$(mkcert -CAROOT)/rootCA.pem" https://shop.thor.test/catalog
The limits of Ingress
Ingress works well for simple HTTP, but it falls short in large environments. It's not a Cilium flaw; it's the resource itself:
- A single role: the same object mixes infrastructure (IPs, certificates) and application routes. There's no native way to split responsibilities between teams.
- Weak multi-tenancy: nothing stops one team's configuration from affecting another's.
- Non-portable annotations: advanced features live in each controller's annotations. What works in one may not work in another.
- Hard to extend: nothing standard for TCP, gRPC, traffic splitting or rewrites.
To fix this, Kubernetes SIG Network created Gateway API, the successor to Ingress.
Gateway API: resources and roles
Gateway API splits configuration into several resources, each designed for a different role. That way you can give each team permission only over its own routes, with regular Kubernetes RBAC.
Each role manages its own resource; Cilium turns it into Envoy configuration. Diagram: The House of Routing.
| Resource | Who manages it | What it defines |
|---|---|---|
| GatewayClass | Infrastructure provider | Which controller implements the Gateways. With Cilium it's called cilium |
| Gateway | Cluster operator | The entry point: listeners with protocol, port, hostname and TLS, and which namespaces can attach routes |
| HTTPRoute, GRPCRoute, TLSRoute | Application teams | Routing rules toward their services |
| ReferenceGrant | Owner of the referenced resource | Explicit permission for cross-namespace references |
Features that depended on annotations in Ingress (traffic splitting, headers, redirects, rewrites, mirroring) are part of the API itself.
Your first Gateway
Cilium doesn't install the Gateway API CRDs: you install them yourself, in the version your Cilium supports, so you don't mix channels. Cilium 1.20 supports Gateway API v1.6.3 on the standard channel:
GW=https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.6.3/config/crd/standard
for crd in gatewayclasses gateways httproutes referencegrants grpcroutes backendtlspolicies tlsroutes; do
kubectl apply --server-side -f $GW/gateway.networking.k8s.io_$crd.yaml
done
helm upgrade cilium cilium/cilium --version 1.20.3 -n kube-system \
--reuse-values --set gatewayAPI.enabled=true
kubectl -n kube-system rollout restart deployment/cilium-operator
kubectl -n kube-system rollout restart daemonset/cilium
kubectl get gatewayclass # cilium · ACCEPTED True
The Gateway listens on port 80 and accepts routes from its own namespace:
# thor-gateway.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: thor-gw
spec:
gatewayClassName: cilium
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same # All would allow routes from any namespace
And the route. The first rule routes by prefix; the second only accepts GET with the x-team: shop header:
# shop-route.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: shop
spec:
parentRefs:
- name: thor-gw
rules:
- matches:
- path:
type: PathPrefix
value: /catalog
backendRefs:
- name: catalog
port: 80
- matches:
- path:
type: PathPrefix
value: /cart
method: GET
headers:
- name: x-team
value: shop
backendRefs:
- name: cart
port: 80
kubectl apply -f thor-gateway.yaml -f shop-route.yaml
kubectl get gateway thor-gw # PROGRAMMED True: Envoy already has the configuration
kubectl get httproute shop -o jsonpath='{.status.parents[0].conditions[*].type}'
# Accepted ResolvedRefs
GATEWAY=$(kubectl get gateway thor-gw -o jsonpath='{.status.addresses[0].value}')
docker run --rm --network kind nicolaka/netshoot curl -s http://$GATEWAY/catalog
docker run --rm --network kind nicolaka/netshoot curl -s -H "x-team: shop" http://$GATEWAY/cart
docker run --rm --network kind nicolaka/netshoot curl -s -o /dev/null -w "%{http_code}\n" http://$GATEWAY/cart
# 404 · without the header it doesn't match any rule
TLS works the same as in Ingress, but you declare it on the Gateway's listener:
listeners:
- name: https
protocol: HTTPS
port: 443
hostname: "shop.thor.test"
tls:
certificateRefs:
- kind: Secret
name: thor-test-cert
Canary, headers and redirects
Canary rollout
Gateway API splits traffic by weight without a service mesh. Deploy a second version of the catalog and send it only 10%:
A canary is a change of weights on a route. Diagram: The House of Routing.
kubectl create deployment catalog-v2 --image=hashicorp/http-echo -- /http-echo -text="catalog v2"
kubectl expose deployment catalog-v2 --port=80 --target-port=5678
# In shop-route.yaml, the /catalog rule
- matches:
- path:
type: PathPrefix
value: /catalog
backendRefs:
- name: catalog
port: 80
weight: 90
- name: catalog-v2
port: 80
weight: 10
# 200 requests and the count per version
docker run --rm --network kind nicolaka/netshoot sh -c \
"for i in \$(seq 200); do curl -s http://$GATEWAY/catalog; echo; done" | sort | uniq -c
# 181 hello from catalog
# 19 catalog v2
If the canary goes well, raise its weight to 50 and then to 100. Clients never notice.
Modify headers
The RequestHeaderModifier and ResponseHeaderModifier filters add, change (set) or remove (remove) headers:
filters:
- type: RequestHeaderModifier
requestHeaderModifier:
add:
- name: x-thor-route
value: catalog
- type: ResponseHeaderModifier
responseHeaderModifier:
set:
- name: x-served-by
value: thor-gateway
With Hubble you can search for flows by those headers: hubble observe -P --http-header "x-thor-route:catalog".
Redirects
The RequestRedirect filter changes the path, host, scheme or status code:
# /store → /catalog with 301 (permanent change)
- matches:
- path:
type: PathPrefix
value: /store
filters:
- type: RequestRedirect
requestRedirect:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /catalog
statusCode: 301
# /web → https://shop.thor.test
- matches:
- path:
type: PathPrefix
value: /web
filters:
- type: RequestRedirect
requestRedirect:
scheme: https
hostname: shop.thor.test
docker run --rm --network kind nicolaka/netshoot curl -sI http://$GATEWAY/store | grep -iE "^HTTP|^location"
# HTTP/1.1 301 Moved Permanently
# location: http://172.18.255.201:80/catalog
Redirect to HTTPS the URLs a person opens in a browser. On APIs used by machines, the redirect comes too late: a misconfigured client has already sent its token over plain HTTP before receiving the 301. For APIs, it's better not to listen on HTTP at all.
gRPC and internal traffic with GAMMA
GRPCRoute
gRPC travels over HTTP/2 and calls service methods. Ingress has no standard way to route it; Gateway API does, with GRPCRoute, which matches by service and method:
apiVersion: gateway.networking.k8s.io/v1
kind: GRPCRoute
metadata:
name: currency
spec:
parentRefs:
- name: thor-gw
rules:
- matches:
- method:
service: shop.v1.CurrencyService
method: GetSupportedCurrencies
backendRefs:
- name: currency
port: 7000
To test it, grpcurl needs the service's .proto definition:
grpcurl -plaintext -proto shop.proto $GATEWAY:80 \
shop.v1.CurrencyService/GetSupportedCurrencies
GAMMA: Gateway API inside the cluster
Up to here, everything was traffic entering the cluster (north-south). GAMMA (Gateway API for Mesh Management and Administration) applies the same routes to traffic between services (east-west). It adds no new resources: the route attaches to a Service instead of a Gateway.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: catalog-internal
spec:
parentRefs:
- kind: Service
group: ""
name: catalog
rules:
- matches:
- path:
type: PathPrefix
value: /v2
backendRefs:
- name: catalog-v2
port: 80
- backendRefs:
- name: catalog
port: 80
Now any pod that calls http://catalog/v2 reaches version 2, without going through the cluster's front door. Keep in mind that GAMMA puts Envoy on that internal path, with its performance cost (chapter 13).
Challenge
Answer before you open the solution.
1. Which Cilium component processes Ingress and Gateway API traffic?
Envoy, the one that already runs on every node. Cilium translates the resources into CiliumEnvoyConfig objects.
2. Your Ingress has no address. What's missing?
An IP for its LoadBalancer service: in the cloud, the provider gives it; in your lab, an LB IPAM pool, plus an announcement (layer 2 or BGP) so the network can reach it.
3. Why does Gateway API separate GatewayClass, Gateway and HTTPRoute?
To separate roles: infrastructure, cluster operator and application teams each manage their own resource, with different permissions.
4. How do you send 5% of traffic to a new version?
With weight in the HTTPRoute's backendRefs: 95 for the current version and 5 for the new one.
What you take away
- Cilium comes with built-in Ingress and Gateway API, on top of the Envoy on every node.
- Ingress works for simple HTTP; its advanced features depend on non-portable annotations.
- Gateway API separates roles and includes routing by header and method, weights, headers, redirects and gRPC out of the box.
- Gateway API CRDs are installed separately, in the version your Cilium supports (v1.6.3 on Cilium 1.20).
- With GAMMA, the same routes work for internal traffic.
In the next chapter: performance. Zone-aware traffic, local redirect, DSR, XDP, Maglev and netkit.
Official resources
- Gateway API Supportdocs.cilium.io
- Kubernetes Ingress Supportdocs.cilium.io
- L2 Announcementsdocs.cilium.io
- Gateway APIgateway-api.sigs.k8s.io
- GAMMAgateway-api.sigs.k8s.io
- Cilium: Up and Running (book)isovalent.com
Source and credits. This chapter summarizes and paraphrases the official book Cilium: Up and Running by Nico Vibert, Filip Nikolic and James Laverack (O'Reilly Media, 2026). The summary was produced with AI and reviewed, verified and approved by Jesús Espinoza. The diagrams and code examples are original work by The House of Routing and were checked against the official Cilium documentation. Cilium: Up and Running, the cover image, and related trade dress are trademarks of O'Reilly Media, Inc. This content is not affiliated with or endorsed by O'Reilly Media or Isovalent.