Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Serve a Gateway and filter at L7 with Cilium

By updated

Improve this page

Cilium can serve the Gateway and HTTPRoute objects of the Gateway API itself: you install their CRDs, enable gatewayAPI.enabled=true, then give the Gateway an address with a CiliumLoadBalancerIPPool. This lesson walks through that path on Cilium 1.20.5, serves an application over HTTP then HTTPS, and sets a CiliumNetworkPolicy that only allows GET on one path. It shows the trap of this combination: the policy cuts off the Gateway's own traffic until you allow the ingress entity. It is aimed at readers who already administer a Cilium cluster without kube-proxy and want to avoid a second entry component.

What you will learn

  • Say what changes when Cilium serves the Gateway API instead of another controller.
  • Install the Gateway API CRDs, enable gatewayAPI.enabled=true and restart the Cilium operator.
  • Explain why a Gateway stays in Programmed=False (AddressNotAssigned), and give it an address.
  • Serve an application over HTTP, then over HTTPS with a Terminate listener.
  • Write a CiliumNetworkPolicy that filters the HTTP method and path, and tell an L7 denial from a network denial.
  • Allow the Gateway's traffic with fromEntities: [ingress], read the denials with Hubble, then remove the feature in the right order.

Prerequisites

The outputs were captured on 18 November 2026 with Cilium 1.20.5. This version does not claim to support Kubernetes 1.37, which the demonstration cluster nevertheless uses. Everything the lesson shows worked, but an unexpected behavior may come from this version gap.

Why have Cilium serve the Gateway API?

A Gateway API needs a controller: a component that reads the Gateway and HTTPRoute objects and configures the entry point. The lesson Kubernetes Gateway API: Gateway, HTTPRoute and route diagnosis uses Traefik, and the lesson Gateway API over HTTPS: serving a cert-manager certificate uses Istio. On a cluster that already has Cilium as its network plugin, Cilium can play this role: the entry point is then served by the same component as the rest of the network.

This changes something that matters for what follows. The traffic that enters through the Gateway is handled by Cilium, so it carries an identity that Cilium's policies know how to read. You can write a rule that talks about the Gateway, and filter at L7 (at the level of the HTTP request: method, path) what reaches the Pod. The sections below show it in order: enable the feature, serve an application, filter.

How do you enable the Gateway API in Cilium?

Enabling it takes three steps, in this order: install the Gateway API CRDs, enable the feature in Cilium, restart the operator. Cilium does not install the CRDs (the definitions of the Gateway, HTTPRoute… objects) itself: without them, it has nothing to serve.

According to the Cilium documentation, the feature also requires two settings on the cluster: kubeProxyReplacement=true and the L7 proxy (l7Proxy=true). The nodes must also provide iptables and its netfilter modules, which redirect the Gateway's traffic to Envoy: without them, connections to the Gateway time out without reaching it. The demonstration cluster already had both settings. cilium status returns KubeProxyReplacement: True, and the cilium-config ConfigMap holds enable-l7-proxy: "true":

Terminal window
kubectl -n kube-system exec ds/cilium -- cilium-dbg status | grep -E '^(Cilium|KubeProxyReplacement):'
kubectl -n kube-system get configmap cilium-config -o yaml | grep -iE 'gateway|l7-proxy|enable-envoy'
kubectl get crd | grep gateway.networking.k8s.io
KubeProxyReplacement: True [enp1s0 10.10.50.14 fe80::5054:8bff:fed2:13 (Direct Routing)]
Cilium: Ok 1.20.5 (v1.20.5-15012141)
egress-gateway-reconciliation-trigger-interval: 1s
enable-l7-proxy: "true"

The third command returns nothing: no Gateway API CRD is installed at the start. You install those of the standard channel in version v1.6.3, the one Cilium 1.20.5 declares, with --server-side:

Terminal window
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.3/standard-install.yaml
customresourcedefinition.apiextensions.k8s.io/backendtlspolicies.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/httproutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/listenersets.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/referencegrants.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/tcproutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/tlsroutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/udproutes.gateway.networking.k8s.io serverside-applied
validatingadmissionpolicy.admissionregistration.k8s.io/safe-upgrades.gateway.networking.k8s.io serverside-applied
validatingadmissionpolicybinding.admissionregistration.k8s.io/safe-upgrades.gateway.networking.k8s.io serverside-applied

This file does not only bring CRDs: the last two lines are a ValidatingAdmissionPolicy named safe-upgrades.gateway.networking.k8s.io and its binding. kubectl delete -f on the same file removes them along with the CRDs. You then list the CRDs. This listing dates from an installation in v1.6.1: its ten names are those of the output above.

Terminal window
kubectl get crd | grep gateway.networking.k8s.io
backendtlspolicies.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-18T04:42:11Z
gatewayclasses.gateway.networking.k8s.io Cluster v1(storage),v1beta1 2026-11-18T04:42:11Z
gateways.gateway.networking.k8s.io Namespaced v1(storage),v1beta1 2026-11-18T04:42:11Z
grpcroutes.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-18T04:42:11Z
httproutes.gateway.networking.k8s.io Namespaced v1(storage),v1beta1 2026-11-18T04:42:11Z
listenersets.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-18T04:42:11Z
referencegrants.gateway.networking.k8s.io Namespaced v1,v1beta1(storage) 2026-11-18T04:42:11Z
tcproutes.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-18T04:42:11Z
tlsroutes.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-18T04:42:11Z
udproutes.gateway.networking.k8s.io Namespaced v1(storage) 2026-11-18T04:42:11Z

Cilium requires seven of these CRDs: GatewayClass, Gateway, HTTPRoute, GRPCRoute, BackendTLSPolicy, ReferenceGrant and TLSRoute. The standard-install.yaml file brings all seven, TLSRoute included, and adds three optional CRDs: ListenerSet, TCPRoute and UDPRoute. Without those three, Cilium disables the matching features, and the lesson does not use them.

Cilium 1.20.5 declares Gateway API version v1.6.3, in its documentation and in its go.mod, and that is the one the lab installs. The installation output above was captured in v1.6.3 on 18 November 2026. The other outputs of the lesson were captured with CRDs in v1.6.1; what they show worked.

Next comes the activation in Cilium. You keep the current values (--reuse-values) and add gatewayAPI.enabled=true:

Terminal window
sudo helm --kubeconfig /etc/kubernetes/admin.conf upgrade cilium cilium/cilium \
-n kube-system --version 1.20.5 --reuse-values \
--set gatewayAPI.enabled=true
kubectl -n kube-system rollout status ds/cilium --timeout=300s
Release "cilium" has been upgraded. Happy Helming!
NAME: cilium
LAST DEPLOYED: Wed Nov 18 04:42:12 2026
NAMESPACE: kube-system
STATUS: deployed
REVISION: 14
DESCRIPTION: Upgrade complete
TEST SUITE: None
Waiting for daemon set "cilium" rollout to finish: 2 out of 3 new pods have been updated...
Waiting for daemon set "cilium" rollout to finish: 2 out of 3 new pods have been updated...
Waiting for daemon set "cilium" rollout to finish: 1 of 3 updated pods are available...
Waiting for daemon set "cilium" rollout to finish: 2 of 3 updated pods are available...
daemon set "cilium" successfully rolled out

Only the first lines of the Helm output are shown. The Cilium agents are replaced one by one, and rollout status ends when all three are ready. You then restart the operator, the cilium-operator Deployment: it is the one that manages the GatewayClass and the Gateways, and the Cilium documentation asks you to restart it after enabling the feature. The cilium GatewayClass itself comes from the Helm chart: the chart creates it during the helm upgrade when the GatewayClass CRD already exists (setting gatewayAPI.gatewayClass.create, set to auto by default).

Terminal window
kubectl -n kube-system rollout restart deploy/cilium-operator
kubectl -n kube-system rollout status deploy/cilium-operator --timeout=180s
deployment.apps/cilium-operator restarted
Waiting for deployment spec update to be observed...
Waiting for deployment "cilium-operator" rollout to finish: 0 out of 2 new replicas have been updated...
Waiting for deployment "cilium-operator" rollout to finish: 0 out of 2 new replicas have been updated...
Waiting for deployment "cilium-operator" rollout to finish: 1 out of 2 new replicas have been updated...
Waiting for deployment "cilium-operator" rollout to finish: 1 old replicas are pending termination...
Waiting for deployment "cilium-operator" rollout to finish: 1 old replicas are pending termination...
Waiting for deployment "cilium-operator" rollout to finish: 1 old replicas are pending termination...
Waiting for deployment "cilium-operator" rollout to finish: 1 old replicas are pending termination...
deployment "cilium-operator" successfully rolled out

What is left is to check that the feature is active. Two readings are enough: the enable-gateway-api key of the ConfigMap, and the GatewayClass named cilium, which the Helm chart created and the operator accepted.

Terminal window
kubectl -n kube-system get configmap cilium-config -o yaml | grep -iE 'gateway-api|enable-envoy|l7-proxy'
kubectl get gatewayclass -o wide
kubectl get gatewayclass cilium -o jsonpath='{.status.conditions}'; echo
enable-envoy-config: "true"
enable-gateway-api: "true"
enable-gateway-api-alpn: "false"
enable-gateway-api-app-protocol: "false"
enable-gateway-api-proxy-protocol: "false"
enable-gateway-api-secrets-sync: "true"
enable-l7-proxy: "true"
gateway-api-hostnetwork-enabled: "false"
gateway-api-hostnetwork-nodelabelselector: ""
gateway-api-secrets-namespace: cilium-secrets
gateway-api-service-externaltrafficpolicy: Cluster
gateway-api-use-remote-address: "true"
gateway-api-xff-num-trusted-hops: "0"
NAME CONTROLLER ACCEPTED AGE DESCRIPTION
cilium io.cilium/gateway-controller True 34s The default Cilium GatewayClass
[{"lastTransitionTime":"2026-11-18T04:42:26Z","message":"Valid GatewayClass","observedGeneration":1,"reason":"Accepted","status":"True","type":"Accepted"}]

enable-gateway-api: "true" confirms the activation. The cilium GatewayClass is Accepted=True: its controller is io.cilium/gateway-controller, and any Gateway that names it in gatewayClassName will be served by Cilium.

How do you declare a Gateway and a route?

You need an application, a Gateway and an HTTPRoute. The application is an echo server that answers vitrine-par-cilium, behind a Service vitrine on port 80:

Terminal window
kubectl create namespace vitrine
kubectl -n vitrine create deployment vitrine --image=hashicorp/http-echo:1.0.0@sha256:fcb75f691c8b0414d670ae570240cbf95502cc18a9ba57e982ecac589760a186 -- /http-echo -text=vitrine-par-cilium -listen=:5678
kubectl -n vitrine expose deployment vitrine --port=80 --target-port=5678
namespace/vitrine created
deployment.apps/vitrine created
service/vitrine exposed

The Gateway has a single HTTP listener on port 80. The route designates it in parentRefs, filters on the host name vitrine.formation.test and sends everything to the Service. Notice that nothing in these objects mentions Cilium except gatewayClassName: cilium.

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: entree
namespace: vitrine
spec:
gatewayClassName: cilium
listeners:
- name: http
protocol: HTTP
port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: vitrine
namespace: vitrine
spec:
parentRefs:
- name: entree
hostnames:
- vitrine.formation.test
rules:
- backendRefs:
- name: vitrine
port: 80

You apply this file (gw.yaml), then look at the state of the Gateway and of the Service:

Terminal window
kubectl apply -f gw.yaml
kubectl -n vitrine get gateway entree -o wide
kubectl -n vitrine get svc -o wide
gateway.gateway.networking.k8s.io/entree created
httproute.gateway.networking.k8s.io/vitrine created
NAME CLASS ADDRESS PROGRAMMED AGE
entree cilium False 18s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
cilium-gateway-entree LoadBalancer 10.99.187.142 <pending> 80:30279/TCP 18s <none>
vitrine ClusterIP 10.98.22.30 <none> 80/TCP 19s app=vitrine

The Gateway is not programmed: PROGRAMMED is False and ADDRESS is empty. Cilium did create a cilium-gateway-entree Service, of type LoadBalancer, whose EXTERNAL-IP stays <pending>. The next section explains why.

Why does the Gateway stay without an address?

Cilium serves the Gateway behind a Service of type LoadBalancer, and this Service waits for an external address. Outside a cloud, nobody gives it one. The conditions of the Gateway and of its route say so:

Terminal window
kubectl -n vitrine get gateway entree -o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}: {.message}{"\n"}{end}'
kubectl -n vitrine get httproute vitrine -o jsonpath='{range .status.parents[*].conditions[*]}{.type}={.status} {.reason}{"\n"}{end}'
Accepted=True Accepted: Gateway successfully scheduled
Programmed=False AddressNotAssigned: Gateway waiting for address
Accepted=True Accepted
ResolvedRefs=True ResolvedRefs

The Gateway is Accepted=True: Cilium took it over. It is Programmed=False with the reason AddressNotAssigned, and the message says it is waiting for an address. The route, for its part, is correct: Accepted and ResolvedRefs are True, so the vitrine Service is found. The only problem is the address.

You provide it with a CiliumLoadBalancerIPPool, a resource that gives Cilium a block of addresses to hand out to LoadBalancer Services (LB-IPAM). The lesson Announce Services to the network with BGP and Cilium details these pools. The block must be a network that yours does not use elsewhere:

apiVersion: cilium.io/v2
kind: CiliumLoadBalancerIPPool
metadata:
name: pool-gateway
spec:
blocks:
- cidr: 172.31.0.0/28
Terminal window
kubectl apply -f pool.yaml
kubectl -n vitrine get svc -o wide
kubectl -n vitrine get gateway entree -o wide
kubectl -n vitrine get gateway entree -o jsonpath='{range .status.conditions[*]}{.type}={.status} {.reason}{"\n"}{end}'
ciliumloadbalancerippool.cilium.io/pool-gateway created
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
cilium-gateway-entree LoadBalancer 10.99.187.142 172.31.0.0 80:30279/TCP 35s <none>
vitrine ClusterIP 10.98.22.30 <none> 80/TCP 36s app=vitrine
NAME CLASS ADDRESS PROGRAMMED AGE
entree cilium 172.31.0.0 True 35s
Accepted=True Accepted
Programmed=True Programmed

With no other step, the Service received 172.31.0.0 and the Gateway moved to Programmed=True. This address is the first of the 172.31.0.0/28 block. The pool's allowFirstLastIPs field decides whether the first and last addresses of a block can be assigned: the BGP lesson explains it.

A Gateway without an address is therefore not a Cilium failure: it is the absence of an address provider, which the pool supplies. On a cloud, it is the provider's load balancer that plays this role.

How do you serve the application over HTTP, then HTTPS?

Once the address is assigned, you send a request to 172.31.0.0 and give the host name with the Host header. The name vitrine.formation.test exists in no DNS: curl -H is enough to tell the route which name you are asking for.

Terminal window
curl -s -m 5 -H 'Host: vitrine.formation.test' http://172.31.0.0/
curl -s -m 5 -o /dev/null -w '%{http_code}\n' -H 'Host: autre.formation.test' http://172.31.0.0/
curl -sI -m 5 -H 'Host: vitrine.formation.test' http://172.31.0.0/ | head -8
vitrine-par-cilium
404
HTTP/1.1 200 OK
x-app-name: http-echo
x-app-version: 1.0.0
date: Wed, 18 Nov 2026 04:43:26 GMT
content-length: 19
content-type: text/plain; charset=utf-8
x-envoy-upstream-service-time: 1
server: envoy

The first call returns the application's answer. The second, with another host name, returns 404: no route declares it, and the Gateway answers by itself. With the headers in hand, server: envoy shows that the request went through an Envoy proxy, the one Cilium uses for L7.

For HTTPS, you add a listener in Terminate mode: the Gateway decrypts the TLS connection and speaks in clear text to the application. It reads its certificate from a TLS Secret. For a test, a self-signed certificate, valid for one day, is enough:

Terminal window
openssl req -x509 -newkey rsa:2048 -nodes -days 1 -subj '/CN=vitrine.formation.test' \
-addext 'subjectAltName=DNS:vitrine.formation.test' \
-keyout vitrine.key -out vitrine.crt
kubectl -n vitrine create secret tls vitrine-tls --cert=vitrine.crt --key=vitrine.key
kubectl -n vitrine patch gateway entree --type=json -p '[{"op":"add","path":"/spec/listeners/-","value":{"name":"https","protocol":"HTTPS","port":443,"hostname":"vitrine.formation.test","tls":{"mode":"Terminate","certificateRefs":[{"name":"vitrine-tls"}]}}}]'
secret/vitrine-tls created
gateway.gateway.networking.k8s.io/entree patched

To check the result, you read the conditions of each listener, then call the Gateway over HTTPS with a curl that only trusts this certificate. --resolve maps the host name to the Gateway's address, which lets curl present the right name in the TLS negotiation.

Terminal window
kubectl -n vitrine get gateway entree -o jsonpath='{range .status.listeners[*]}{.name}: {range .conditions[*]}{.type}={.status} {end}{"\n"}{end}'
curl -s -m 5 --cacert vitrine.crt --resolve vitrine.formation.test:443:172.31.0.0 https://vitrine.formation.test/
echo | openssl s_client -connect 172.31.0.0:443 -servername vitrine.formation.test 2>/dev/null | openssl x509 -noout -subject -issuer
http: ResolvedRefs=True Accepted=True Programmed=True
https: ResolvedRefs=True Accepted=True Programmed=True
vitrine-par-cilium
subject=CN = vitrine.formation.test
issuer=CN = vitrine.formation.test

Both listeners are Programmed=True, https included: ResolvedRefs=True means Cilium found the vitrine-tls Secret. The HTTPS request returns the application's answer. The subject and the issuer are identical (CN = vitrine.formation.test): the certificate is self-signed, which is expected here. In production, you have cert-manager issue and renew it, as the lesson Gateway API over HTTPS: serving a cert-manager certificate shows for Istio.

On Cilium's side, the Gateway left three objects, which you can list: a CiliumEnvoyConfig that holds the proxy configuration, the cilium-gateway-entree Service (which now exposes ports 80 and 443), and an EndpointSlice of the same name.

Terminal window
kubectl -n vitrine get ciliumenvoyconfig -o name
kubectl -n vitrine get svc,endpointslices -o wide
ciliumenvoyconfig.cilium.io/cilium-gateway-entree
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/cilium-gateway-entree LoadBalancer 10.99.187.142 172.31.0.0 80:30279/TCP,443:30410/TCP 54s <none>
service/vitrine ClusterIP 10.98.22.30 <none> 80/TCP 55s app=vitrine
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
endpointslice.discovery.k8s.io/cilium-gateway-entree IPv4 9999 192.192.192.192 54s
endpointslice.discovery.k8s.io/vitrine-99298 IPv4 5678 10.244.2.49 55s

No proxy Pod appears in the vitrine namespace. The 192.192.192.192 address of the Gateway's EndpointSlice is a dummy address set by Cilium: it is the address of no Pod, and you do not use it.

How do you filter the HTTP method and path with a CiliumNetworkPolicy?

A Kubernetes NetworkPolicy reasons in addresses and ports. A CiliumNetworkPolicy (CNP) can go further: under toPorts, a rules.http block limits the allowed requests to a method and a path. This is L7 filtering. It requires the L7 proxy to be active, which is the case here. The method and the path are regular expressions: the refusal of /admin, further down, shows that path: / only allows the root here.

You start with two clients, client (label app=client) and intrus (app=intrus), which run curl in the same namespace, then you check that before any policy both reach vitrine:

Terminal window
kubectl -n vitrine run client --image=curlimages/curl:8.17.0@sha256:935d9100e9ba842cdb060de42472c7ca90cfe9a7c96e4dacb55e79e560b3ff40 --labels=app=client --restart=Never --command -- sleep 36000
kubectl -n vitrine run intrus --image=curlimages/curl:8.17.0@sha256:935d9100e9ba842cdb060de42472c7ca90cfe9a7c96e4dacb55e79e560b3ff40 --labels=app=intrus --restart=Never --command -- sleep 36000
kubectl -n vitrine wait --for=condition=Ready pod/client pod/intrus --timeout=120s
kubectl -n vitrine exec client -- curl -s -m 5 -o /dev/null -w '%{http_code}\n' http://vitrine/
kubectl -n vitrine exec intrus -- curl -s -m 5 -o /dev/null -w '%{http_code}\n' http://vitrine/
pod/client created
pod/intrus created
pod/client condition met
pod/intrus condition met
200
200

Both Pods get 200. The policy below protects the app=vitrine Pods. It only accepts the app=client Pods, on port 5678 (the application's port, not the Service's port 80), and for them only the GET method on the / path:

apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: vitrine-get-seulement
namespace: vitrine
spec:
endpointSelector:
matchLabels:
app: vitrine
ingress:
- fromEndpoints:
- matchLabels:
app: client
toPorts:
- ports:
- port: "5678"
protocol: TCP
rules:
http:
- method: GET
path: /

You apply it, then try three requests from client and one from intrus:

Terminal window
kubectl apply -f l7.yaml
kubectl -n vitrine exec client -- curl -s -m 5 -w '\n%{http_code}\n' http://vitrine/
kubectl -n vitrine exec client -- curl -s -m 5 -w '\n%{http_code}\n' -X POST http://vitrine/
kubectl -n vitrine exec client -- curl -s -m 5 -w '\n%{http_code}\n' http://vitrine/admin
kubectl -n vitrine exec intrus -- curl -s -m 5 -o /dev/null -w '%{http_code}\n' http://vitrine/
ciliumnetworkpolicy.cilium.io/vitrine-get-seulement created
vitrine-par-cilium
200
Access denied
403
Access denied
403
000
command terminated with exit code 28

There are two kinds of denial, and you need to know how to recognize them. For client, the GET / goes through (200), but the POST / and the GET /admin receive 403 and the text Access denied: the connection is accepted, it is the request that the L7 proxy refuses. For intrus, nothing answers: curl returns 000 and exit code 28 (timeout). No rule allows it, so the connection is cut before any HTTP request.

You can also read the state of the policy. Valid means Cilium understood it, not that it does what you expect:

Terminal window
kubectl -n vitrine get cnp vitrine-get-seulement -o jsonpath='{.status.conditions}'; echo
[{"lastTransitionTime":"2026-11-18T04:44:33Z","message":"Policy validation succeeded","status":"True","type":"Valid"}]

Why does the L7 policy cut off the Gateway?

Right after the policy, you call the Gateway as before, and it no longer answers:

Terminal window
curl -s -m 5 -o /dev/null -w '%{http_code}\n' -H 'Host: vitrine.formation.test' http://172.31.0.0/
000

The Gateway is not an app=client Pod. The traffic leaving Cilium's proxy for vitrine carries a reserved identity, reserved:ingress, and the policy does not allow it: its traffic is cut, like that of intrus. You read this identity in Cilium's list:

Terminal window
kubectl -n kube-system exec ds/cilium -- cilium-dbg identity list | grep -E 'reserved:ingress|ID'
ID LABELS
8 reserved:ingress

The reserved ingress identity has number 8. The policy must therefore allow it, with the fromEntities field: an entity is a name that Cilium gives to a group of reserved identities (here, the entry traffic served by Cilium). You add a second ingress rule to the policy, with the same http rules. This keeps the L7 filtering for the Gateway's traffic:

Terminal window
kubectl -n vitrine patch cnp vitrine-get-seulement --type=json -p '[{"op":"add","path":"/spec/ingress/-","value":{"fromEntities":["ingress"],"toPorts":[{"ports":[{"port":"5678","protocol":"TCP"}],"rules":{"http":[{"method":"GET","path":"/"}]}}]}}]'
kubectl -n vitrine get cnp vitrine-get-seulement -o yaml | sed -n '/^spec/,/^status/p'
ciliumnetworkpolicy.cilium.io/vitrine-get-seulement patched
spec:
endpointSelector:
matchLabels:
app: vitrine
ingress:
- fromEndpoints:
- matchLabels:
app: client
toPorts:
- ports:
- port: "5678"
protocol: TCP
rules:
http:
- method: GET
path: /
- fromEntities:
- ingress
toPorts:
- ports:
- port: "5678"
protocol: TCP
rules:
http:
- method: GET
path: /
status:

The policy now has two ingress rules: one for the app=client Pods, the other for the ingress entity, with the same GET /. The diagram shows the three paths that reach the Pod. Follow the Gateway's line: it passes the policy thanks to the ingress entity. The client Pod passes thanks to its label, and intrus, with no rule, stays cut off.

Three paths reach the L7 policy of the vitrine Pod, which only allows GET on the / path. The outside curl goes through the Gateway entree, which carries the ingress identity, allowed by the fromEntities rule. The client Pod is allowed by its label. The intrus Pod is not allowed: its connection is cut. An allowed GET / request reaches the vitrine Pod and returns 200. A POST request, or a request to another path, receives 403 Access denied.ingress allowedallowedcutGET /: 200POST, other path​     curl from outside​     Gateway entree​     ingress identityclient Podintrus PodL7 policyof the vitrine PodGET / onlyvitrine Pod403 Access denied
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

You check the four cases: GET and POST through the Gateway, HTTPS, and intrus.

Terminal window
curl -s -m 5 -w '\n%{http_code}\n' -H 'Host: vitrine.formation.test' http://172.31.0.0/
curl -s -m 5 -w '\n%{http_code}\n' -X POST -H 'Host: vitrine.formation.test' http://172.31.0.0/
curl -s -m 5 --cacert vitrine.crt --resolve vitrine.formation.test:443:172.31.0.0 https://vitrine.formation.test/
kubectl -n vitrine exec intrus -- curl -s -m 5 -o /dev/null -w '%{http_code}\n' http://vitrine/
vitrine-par-cilium
200
Access denied
403
vitrine-par-cilium
000
command terminated with exit code 28

The Gateway answers 200 again for GET /, over HTTP as well as HTTPS. A POST through the Gateway receives 403: the L7 rule also applies to the traffic that arrives through it, not only to the Pods of the cluster. intrus is still cut off. The effect of a fromEntities rule without rules.http was not measured.

How do you read L7 denials in Hubble?

Hubble, Cilium's observation tool, displays the HTTP requests seen by the L7 proxy, with their verdict. The lesson Hubble: observe, measure and audit network flows explains the tool and its metrics. What matters here is where you run it. hubble observe run in a Cilium agent only sees the traffic of its node, and ds/cilium picks an agent at random: the command can return an empty list even though the denials exist. You must target the agent of the node of the Pod that receives the requests.

This test was done separately, in an essai-l7 namespace: a serveur Pod on net-w2, protected by a get-seulement policy of the same type as the previous one (GET / only for the app=client Pods), and a relance Pod on net-w1 that sends a POST /commandes then a GET / in a loop. You first find the agent of the server's node:

Terminal window
kubectl -n kube-system get pods -l k8s-app=cilium --field-selector spec.nodeName=net-w2.lab -o name

In the demonstration, it is cilium-j87gp. The HTTP requests seen by this node:

Terminal window
kubectl -n kube-system exec pod/cilium-j87gp -c cilium-agent -- hubble observe --namespace essai-l7 --protocol http --last 6
Nov 18 04:57:04.209: essai-l7/relance:47930 (ID:4317) -> essai-l7/serveur:5678 (ID:11356) http-request FORWARDED (HTTP/1.1 GET http://serveur/)
Nov 18 04:57:04.210: essai-l7/relance:47930 (ID:4317) <- essai-l7/serveur:5678 (ID:11356) http-response FORWARDED (HTTP/1.1 200 0ms (GET http://serveur/))
Nov 18 04:57:06.216: essai-l7/relance:47946 (ID:4317) -> essai-l7/serveur:5678 (ID:11356) http-request DROPPED (HTTP/1.1 POST http://serveur/commandes)
Nov 18 04:57:06.216: essai-l7/relance:47946 (ID:4317) <- essai-l7/serveur:5678 (ID:11356) http-response FORWARDED (HTTP/1.1 403 0ms (POST http://serveur/commandes))
Nov 18 04:57:06.221: essai-l7/relance:47950 (ID:4317) -> essai-l7/serveur:5678 (ID:11356) http-request FORWARDED (HTTP/1.1 GET http://serveur/)
Nov 18 04:57:06.221: essai-l7/relance:47950 (ID:4317) <- essai-l7/serveur:5678 (ID:11356) http-response FORWARDED (HTTP/1.1 200 0ms (GET http://serveur/))

Look at the verdict column. The GET / gives a FORWARDED request then a 200 response. The POST /commandes gives a DROPPED request, followed by a 403 response: the request is refused and the proxy returns the 403 itself. The word FORWARDED on the 403 response therefore does not mean the request went through: only the http-request line carries the policy's verdict. To keep only the denials, you filter on the verdict:

Terminal window
kubectl -n kube-system exec pod/cilium-j87gp -c cilium-agent -- hubble observe --namespace essai-l7 --verdict DROPPED --last 4
Nov 18 04:57:00.165: essai-l7/relance:43996 (ID:4317) -> essai-l7/serveur:5678 (ID:11356) http-request DROPPED (HTTP/1.1 POST http://serveur/commandes)
Nov 18 04:57:02.186: essai-l7/relance:44020 (ID:4317) -> essai-l7/serveur:5678 (ID:11356) http-request DROPPED (HTTP/1.1 POST http://serveur/commandes)
Nov 18 04:57:04.203: essai-l7/relance:47924 (ID:4317) -> essai-l7/serveur:5678 (ID:11356) http-request DROPPED (HTTP/1.1 POST http://serveur/commandes)
Nov 18 04:57:06.216: essai-l7/relance:47946 (ID:4317) -> essai-l7/serveur:5678 (ID:11356) http-request DROPPED (HTTP/1.1 POST http://serveur/commandes)

You find the refused POST requests, one every two seconds, with the method and the path. Run in the agents of net-w1 (the client's node) and net-cp (unrelated), the same --protocol http command returns nothing: only the agent of the node of the receiving Pod sees these requests. For a view of the whole cluster, you have to go through Hubble Relay, which this lesson did not measure. The hubble command is not installed on the nodes: you run it in the agent.

How do you remove the Gateway API without breaking Helm?

The order of removal matters. If you delete the Gateway API CRDs first while Cilium still expects them, the next helm upgrade fails, because the Helm release contains a GatewayClass and its type no longer exists:

Error: UPGRADE FAILED: unable to build kubernetes objects from current release manifest: resource mapping not found for name: "cilium" namespace: "" from "": no matches for kind "GatewayClass" in version "gateway.networking.k8s.io/v1"
ensure CRDs are installed first

This message was obtained with the CRDs absent, while the release still had the Gateway API enabled. It does not talk about the activation, it only says that the CRDs are missing. The remedy is the order: you first disable the Gateway API in Cilium, then delete the GatewayClass and the CRDs.

Terminal window
helm upgrade cilium cilium/cilium -n kube-system --version 1.20.5 --reuse-values --set gatewayAPI.enabled=false
kubectl delete gatewayclass cilium --ignore-not-found
kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.3/standard-install.yaml --ignore-not-found

The Helm command above was not replayed as is: the cluster was put back to its original values by the lab's cleanup tool. The two kubectl delete commands were run afterwards, in this order, with the v1.6.1 file; the delete of the v1.6.3 file removes the CRDs, the ValidatingAdmissionPolicy and its binding in the same way. You check that the configuration has disappeared and that Helm can still read the release:

Terminal window
kubectl -n kube-system get configmap cilium-config -o yaml | grep -E 'enable-gateway-api|enable-wireguard'
kubectl get crd | grep -c gateway.networking.k8s.io
helm upgrade cilium cilium/cilium --version 1.20.5 -n kube-system --reuse-values --dry-run=client > /dev/null && echo 'release lisible par Helm'
0
release lisible par Helm

The first command returns no line: the enable-gateway-api key has disappeared from the ConfigMap (the search also targets enable-wireguard, which is absent too). The 0 says that no gateway.networking.k8s.io CRD remains, and the Helm dry-run succeeds: the release is readable again.

This removal still leaves three Cilium CRDs, which the search on gateway.networking.k8s.io does not see: ciliumenvoyconfigs.cilium.io, ciliumclusterwideenvoyconfigs.cilium.io and ciliumgatewayclassconfigs.cilium.io. They did not exist at the start of the lab. They are there after it has enabled the Gateway API and applied an L7 policy, and disabling the Gateway API does not remove them (measured by the lab repository on 18 November 2026, Cilium 1.20.5 and Kubernetes 1.37.2). Which of the two steps creates them, and what deleting them changes, was not measured. Only the lab's cleanup tool deletes them, to put the cluster back in its starting state. kubectl get crd | grep -E 'envoyconfigs|gatewayclassconfigs' shows all three.

The objects of the demonstration are removed along with the namespace:

Terminal window
kubectl delete namespace vitrine
kubectl delete ciliumloadbalancerippool pool-gateway

Troubleshooting

Start with the Gateway's conditions (kubectl -n <ns> get gateway <name> -o jsonpath='{.status.conditions}'): they say whether Cilium accepted it and whether it has an address.

SymptomLikely causeSolution
kubectl get gatewayclass returns nothingThe Gateway API CRDs are missing, or the operator was not restarted after enabling the featurekubectl get crd | grep gateway.networking.k8s.io, install the CRDs, then kubectl -n kube-system rollout restart deploy/cilium-operator
The Gateway stays Programmed=False, reason AddressNotAssigned, and the cilium-gateway-<name> Service is <pending>No address pool can serve the LoadBalancer ServiceCreate a CiliumLoadBalancerIPPool with a free block: the address arrives with no other step
After an L7 CiliumNetworkPolicy, the Gateway no longer answers (curl returns 000, code 28) but the allowed Pods answerThe Gateway's traffic carries the reserved ingress identity, which the policy does not allowAdd a fromEntities: [ingress] rule with the same http rules
403 and Access denied for a request you thought was allowedThe method or the path is not in rules.http: the denial comes from the L7 proxy, not from the networkCompare the request (curl -v) with the policy's method and path, then read hubble observe --verdict DROPPED on the agent of the receiving Pod
curl returns 000 (code 28) for a Pod that is in no ruleNo fromEndpoints rule allows it: the connection is cut before any HTTP requestAdd its label to a rule, or accept this denial if it is intended
hubble observe --protocol http returns nothing although requests are deniedThe command is run in an agent that is not on the node of the receiving PodFind the agent with --field-selector spec.nodeName=<node> and run the command inside it
helm upgrade fails on no matches for kind "GatewayClass"The Gateway API CRDs were removed before the feature was disabled in CiliumReinstall the CRDs, disable gatewayAPI.enabled, then only remove the CRDs

Put it into practice

The lab starts from a Cilium cluster without kube-proxy, without Gateway API CRDs and without a load balancer, with a fiches application and a lecteur Pod in the catalogue namespace. It has you install the v1.6.3 CRDs and enable the Gateway API in Cilium, then serve fiches.formation.test through a Gateway. You run into AddressNotAssigned and create a CiliumLoadBalancerIPPool to solve it. You then write a policy that allows GET / for lecteur and refuses POST / with a 403, then restore the Gateway with the ingress entity. The validation reads the Gateway's conditions, then sends real requests: GET and POST through the Gateway, and GET and POST from lecteur. It judges the state of the cluster, never the commands typed.

Key points

  • Cilium serves the Gateway API after three steps in this order: install the CRDs (standard channel, --server-side), enable gatewayAPI.enabled=true, restart deploy/cilium-operator. The cilium GatewayClass must be Accepted=True.
  • Cilium requires kubeProxyReplacement=true and the L7 proxy (enable-l7-proxy); both were already active on the demonstration cluster.
  • A Gateway without an address is Programmed=False, reason AddressNotAssigned: a CiliumLoadBalancerIPPool gives the address to the cilium-gateway-<name> Service, and the Gateway moves to Programmed=True.
  • An HTTPS listener in Terminate mode reads its certificate from a TLS Secret (certificateRefs); routing by host name returns 404 for a name that no route declares.
  • A CiliumNetworkPolicy filters the method and the path with toPorts.rules.http. A refused request returns 403 Access denied; an unauthorized client is cut at the network level (000, code 28).
  • The Gateway's traffic carries the reserved ingress identity: an L7 policy that does not allow it cuts off the Gateway. You allow it with fromEntities: [ingress] and the same http rules, which then also apply to the Gateway's traffic.
  • hubble observe only sees the node of its agent: to read an L7 denial, target the agent of the receiving Pod's node, with --protocol http or --verdict DROPPED. The policy's verdict is on the http-request line.
  • To remove the feature, disable gatewayAPI.enabled in Cilium before deleting the CRDs, otherwise helm upgrade fails on no matches for kind "GatewayClass".

Knowledge check

Eight questions drawn from twelve: enabling the Gateway API in Cilium, the Gateway's address, the L7 policy, the ingress entity, reading denials in Hubble and removal in the right order. A missed answer points to the section to reread.

Knowledge check

Check what you have learned with this interactive quiz

8 questions
6 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer