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

CKNE exercises: timed networking practice

By updated

Improve this page

Logo Kubernetes

These 18 exercises train the networking skills the CKNE asks for, one domain of the blueprint at a time: CNI plugin and Pod addresses, Services and DNS, advanced traffic, network security, observability. Each exercise gives a short statement, a target time, the way to check the result on the cluster, and a collapsed solution. The solutions reuse the commands and manifests of the course lessons, with their versions: each exercise names the lesson that teaches it. Start a timer, try without opening the solution, then compare. A graded final project with no hints (the capstone) ends the page: it chains three of these skills across two clusters.

The official blueprint has five domains (see Prepare for the CKNE). The exercises follow its order and its weights: 4 exercises for Core Infrastructure and CNI (15%), 4 for Service Networking and DNS (25%), 4 for Advanced Traffic Management (20%), 4 for Network Security and Policy (25%) and 2 for Observability (15%).

What you will learn

  • Read the network state of a cluster and verify a task on that state, not on the manifest you wrote.
  • Chain a network diagnosis by telling a refusal, a loss and a DNS failure apart.
  • Configure a Service, a Gateway, a NetworkPolicy or an L7 policy within a time limit.
  • Announce a Service over BGP, link two clusters and send traffic out through a gateway.
  • Reset the cluster between two exercises.

Which environments should you prepare?

The exercises do not all run on the same cluster: a CKNE domain needs a CNI plugin, a mesh or a router that the others do not have. The table lists, for each environment, what it contains, the lesson that describes it step by step and the exercises played on it. Prepare the environment of an exercise before you start the timer: the target time does not include the installation.

Env.ContentLesson that describes itExercises
Akind 0.33.0, one control plane and three workers in v1.37.0, kindnet plugin, kind-multi.yaml filePod Networking1, 2, 5, 6, 7, 13
Bkind with ports 8080 and 8443 of the workstation published (kind-expo.yaml file), Gateway API v1.6.2 CRDs, TraefikGateway API8
Ckubeadm cluster on Ubuntu 24.04 virtual machines, Kubernetes v1.37.2, Calico, ssh and sudo access to the nodesCapture a Pod's traffic3
Dthree-node kubeadm cluster (net-cp.lab, net-w1.lab, net-w2.lab), Kubernetes v1.37.2, no kube-proxy, Cilium 1.20.5 with Hubble, cilium CLI v0.20.3 and cilium Helm repository declared on the node where you type kubectlCilium without kube-proxy and Hubble4, 10, 11, 14, 17, 18
Ekubeadm cluster with Istio 1.32.0 in ambient mode, cert-manager v1.21.3, Gateway API v1.6.1Gateway API over HTTPS9, 15
Ftwo single-node kubeadm clusters, contexts cluster-1 and cluster-2, Cilium with ClusterMesh, cilium CLI v0.20.3ClusterMesh12
Gsingle-node kind cluster in v1.37.0, Istio 1.32.0 installed with the demo profile, production namespace injected with a sidecarPod-to-pod mTLS16

Exercise 16 runs on environment G, where Istio runs as a sidecar, and not on environment E, where it runs in ambient mode. The lessons also say what each exercise assumes is already installed: Multus for exercise 4, the FRR router and the BGP control plane for exercise 10, the egress gateway for exercise 11. The outputs in the lessons come from Cilium 1.20.4 or 1.20.5, and the commands are the same. In environments D and F, the cilium CLI is used by exercises 10 (cilium bgp peers) and 12 (cilium clustermesh), and the cilium Helm repository by exercise 18 (helm upgrade): check that both are installed before you start the timer. The CKNE exam allows the Kubernetes, Cilium and Istio documentation (see Prepare for the CKNE): practice looking things up rather than memorizing everything.

CKNE reflexes

Set these reflexes before the first exercise. Each one keeps you from concluding on a bad reading, which costs more minutes than one extra command. The table gathers them with what each one teaches.

ReflexCommandWhat you read from it
Bound every network testkubectl exec <pod> -- wget -qO- -T 3 http://<target>An immediate failure (Connection refused) means a packet arrived and no program is listening. A download timed out means nobody answered: look on the network side
Check the endpoints, not the Servicekubectl get endpointslice -l kubernetes.io/service-name=<svc>A Service without endpoints is created without error and serves nobody
Name the plugin without guessingkubectl -n kube-system get daemonsetEvery network plugin shows up there, whatever its name
Read the state in the conditionskubectl get <resource> -o jsonpath=... on status.conditionskubectl get httproute only shows the hosts: Accepted and ResolvedRefs are read in the status
Wait for propagationa bounded loop timeout 120 sh -c 'until ... ; do sleep 2; done'A modified policy or Corefile does not act within the second: testing too early gives the old answer, and the two-minute bound avoids waiting forever
Name the cluster--context cluster-1 on every commandWith two clusters, a command without a context goes to the wrong one

Also keep the usual aliases of the Kubernetes exams, which you have already set up for the CKA or the CKS:

Terminal window
alias k=kubectl
alias kn='kubectl config set-context --current --namespace'
export do="--dry-run=client -o yaml"
source <(kubectl completion bash)
complete -F __start_kubectl k

Domain 1, Core Infrastructure and CNI (15%)

These four exercises cover where Pod addresses come from, repairing a CNI plugin, diagnosis at the packet level and the second network of a Pod.


Exercise 1: Read the cluster's address ranges

This exercise checks that you know where Pod addresses come from before you diagnose one. Target time: 4 minutes

ContextEnvironment A, cluster demo-reseau
TaskFind the Pod range of the cluster, the subnet of each of the four nodes, the Pod capacity of the demo-reseau-worker worker, then the CNI plugin configuration laid down on that worker
ValidationYou get 10.244.0.0/16, four distinct /24 subnets, the capacity 110, and a 10-kindnet.conflist file whose IPAM is host-local with the subnet of the worker
Source lessonPod Networking, section "Where do Pod addresses come from?"
Solution
Terminal window
kubectl cluster-info dump | grep -m1 cluster-cidr
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.podCIDR}{"\n"}{end}'
kubectl get node demo-reseau-worker -o jsonpath='{.status.capacity.pods}{"\n"}'
docker exec demo-reseau-worker cat /etc/cni/net.d/10-kindnet.conflist

The first command reads the --cluster-cidr argument of the kube-controller-manager. The second gives the spec.podCIDR field of each node: the subnet number does not follow the worker number (worker2 carries 10.244.3.0/24), so always read it with the command. The node advertises 110 Pods, the default maxPods value of the kubelet: size on that figure, not on the 254 addresses of a /24. The configuration file shows "type": "host-local" and "subnet": "10.244.1.0/24": it is the CNI plugin that assigns the address, neither the API server nor the kubelet.

On another plugin, these values change. With Calico, Pods get their addresses from /26 blocks of the pool and do not follow the podCIDR of the node.


Exercise 2: Repair a node whose CNI plugin no longer answers

A node without a CNI configuration leaves its Pods in ContainerCreating, and putting the file back is not enough. Target time: 8 minutes

ContextEnvironment A, namespace ws-podnet, node demo-reseau-worker3
Setupdocker exec demo-reseau-worker3 sh -c 'mv /etc/cni/net.d/10-kindnet.conflist /root/10-kindnet.conflist.sauve', then create the Pod pas-de-reseau (busybox, nodeSelector on kubernetes.io/hostname: demo-reseau-worker3)
TaskFind why the Pod stays in ContainerCreating, then make the node Ready and the Pod Running
Validationkubectl wait --for=condition=Ready node/demo-reseau-worker3 succeeds and kubectl -n ws-podnet get pod pas-de-reseau shows 1/1 Running
Source lessonPod Networking, section "The Pod is stuck in ContainerCreating"
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: pas-de-reseau
namespace: ws-podnet
spec:
nodeSelector:
kubernetes.io/hostname: demo-reseau-worker3
containers:
- name: busybox
image: busybox:1.38.0@sha256:a46257e06c82ad85242d0d38077d0a52d9896389ca60a1a59d3463db586e5fa4
command: ["sleep", "3600"]
EOF
# Diagnosis: read the Pod events
kubectl -n ws-podnet describe pod pas-de-reseau | sed -n '/Events:/,$p'
# Repair: put the file back, then restart the plugin Pod on this node
docker exec demo-reseau-worker3 sh -c 'mv /root/10-kindnet.conflist.sauve /etc/cni/net.d/10-kindnet.conflist'
kubectl -n kube-system delete pod -l app=kindnet --field-selector spec.nodeName=demo-reseau-worker3
kubectl wait --for=condition=Ready node/demo-reseau-worker3 --timeout=120s
kubectl -n ws-podnet wait --for=condition=Ready pod/pas-de-reseau --timeout=120s

The events end with cni plugin not initialized: the runtime no longer finds a network configuration, and the node goes NotReady. Putting the file back alone repairs nothing: containerd saw the file disappear, but does not reload it when it returns. Deleting the kindnet Pod of the node is enough: the recreated Pod rewrites the file in a way that containerd detects, and the node goes back to Ready in about fifteen seconds. With Calico, do the same on the calico-node Pod.


Exercise 3: Capture a Pod's traffic and name the failure

An application's logs say that a connection failed, never why: only a capture tells a refusal, a loss and a DNS failure apart. Target time: 8 minutes

ContextEnvironment C, a client Pod calls a Service and receives Connection timed out after 3001 milliseconds
TaskFind the node and the interface of the client Pod, capture 12 seconds of its traffic into a file, read the file back and say whether the failure is a refusal, a loss or a DNS failure
SetupPlay the lesson's lab, dsoxlab run k8s-capturer-le-trafic-d-un-pod ("Capture a Pod's traffic and name the cause of each failure"), which sets up the client Pod and its failure
ValidationThe .pcap file exists, your reading names the type of failure by citing the packet that proves it, and you name the Kubernetes resource that causes it
Source lessonCapture a Pod's traffic, sections "How do you find a Pod's interface on its node?" and "How do you read a capture: refusal, loss or DNS?"
Solution
Terminal window
# Node and address of the client Pod
kubectl get pods -o wide
# On that node: the interface that leads to the Pod's address
ip route get <Pod-IP> | grep -o 'dev [^ ]*'
# Capture 12 seconds, writing to a file, then read it back
sudo timeout 12 tcpdump -i <interface> -nn -U -w /tmp/perte.pcap
sudo tcpdump -nn -r /tmp/perte.pcap
# Confirm the cause on the Kubernetes side
kubectl get networkpolicy

With Calico, the interface is named cali followed by 11 characters. Then ask the capture three questions: did the name resolve, did a SYN go out, what came back and how fast. A loss shows the same SYN (same source port, same sequence number) retransmitted one second apart, with no SYN-ACK and no RST. A refusal shows an [R.] a few microseconds after the SYN. A DNS failure shows NXDomain answers and no SYN. The capture does not say who drops the packet: here, kubectl get networkpolicy points to the ingress policy of the target.

A capture taken on the client side shows the address of the Service, never that of the server Pod: the translation happens further along, in the iptables rules of the node.


Exercise 4: Give a Pod a second interface

A Pod has only one network interface by default; Multus adds one through a NetworkAttachmentDefinition object. Target time: 8 minutes

ContextEnvironment D with Multus 4.3.2 installed and cni.exclusive=false set on Cilium
TaskDeclare in the multus-demo namespace a reseau-stockage network of type macvlan, then start a client Pod on net-w1.lab and a serveur Pod on net-w2.lab, both attached to that network. Their net1 interface carries 192.168.100.11/24 for client and 192.168.100.12/24 for serveur: these are not the addresses of the nodes
Validationkubectl -n multus-demo exec client -- ip -4 addr shows a net1 interface at 192.168.100.11/24, and wget -qO- http://192.168.100.12:8080/ returns bonjour-du-reseau-stockage
Source lessonGive a Pod a second interface with Multus
Solution
Terminal window
kubectl create namespace multus-demo
kubectl apply -f - <<'EOF'
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: reseau-stockage
namespace: multus-demo
spec:
config: |
{
"cniVersion": "1.0.0",
"name": "reseau-stockage",
"type": "macvlan",
"master": "enp1s0",
"mode": "bridge",
"ipam": { "type": "static" }
}
EOF
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: client
namespace: multus-demo
annotations:
k8s.v1.cni.cncf.io/networks: '[{"name": "reseau-stockage", "ips": ["192.168.100.11/24"]}]'
spec:
nodeName: net-w1.lab
containers:
- name: c
image: busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec
command: ["sleep", "3600"]
---
apiVersion: v1
kind: Pod
metadata:
name: serveur
namespace: multus-demo
annotations:
k8s.v1.cni.cncf.io/networks: '[{"name": "reseau-stockage", "ips": ["192.168.100.12/24"]}]'
spec:
nodeName: net-w2.lab
containers:
- name: c
image: busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec
command: ["sh", "-c", "echo bonjour-du-reseau-stockage > /tmp/index.html; httpd -f -p 8080 -h /tmp"]
EOF
kubectl -n multus-demo wait --for=condition=Ready pod/client pod/serveur --timeout=180s
kubectl -n multus-demo exec client -- ip -4 addr
kubectl -n multus-demo exec client -- wget -qO- -T 5 http://192.168.100.12:8080/

The master field names the network card of the node: enp1s0 is the one on the lesson's machines, ip -br link gives yours. With ipam: static, the address comes from the Pod's annotation and carries its mask (/24). The IP column of kubectl get pods only shows the address of the primary network: the second one is read in the Pod or in the k8s.v1.cni.cncf.io/network-status annotation. The net1 traffic does not go through Cilium, so no NetworkPolicy filters it.


Domain 2, Service Networking and DNS (25%)

This domain weighs as much as network security, and its failures are often silent: a Service without endpoints, a faulty Corefile that keeps running, a route that is accepted but not resolved. The four exercises therefore ask you to verify the state, never to conclude from the creation.


Exercise 5: A Service that no longer answers, and what serves it

A created Service is not a Service that serves: the failure only shows in the endpoints. Target time: 8 minutes

ContextEnvironment A, namespace default, Deployment reponse (3 replicas, label app=reponse), Service reponse and Pod client
SetupCreate the Deployment, the Service and the client Pod of the lesson, then break the Service: kubectl patch svc reponse -p '{"spec":{"selector":{"app":"reponses"}}}'
TaskFind why wget http://reponse is refused from client, restore the Service, then read the mode of kube-proxy and the rules that translate the Service address on a node
ValidationThe EndpointSlice lists three addresses on port 8080, wget -qO- http://reponse returns Je suis reponse-..., the ConfigMap declares mode: iptables and the KUBE-SERVICES chain contains one -j KUBE-SVC-* rule per Service port
Source lessonServices, section "What happens when the selector finds no Pod?", and Pod Networking, section "The role of kube-proxy"
Setup (outside the timer)
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: reponse
spec:
replicas: 3
selector:
matchLabels:
app: reponse
template:
metadata:
labels:
app: reponse
spec:
containers:
- name: reponse
image: busybox:1.38.0@sha256:a46257e06c82ad85242d0d38077d0a52d9896389ca60a1a59d3463db586e5fa4
command: ["sh", "-c"]
args:
- mkdir -p /www && echo "Je suis $(hostname)" > /www/index.html && httpd -f -p 8080 -h /www
ports:
- containerPort: 8080
EOF
kubectl rollout status deployment/reponse
kubectl expose deployment reponse --name=reponse --port=80 --target-port=8080
kubectl run client --image=busybox:1.38.0@sha256:a46257e06c82ad85242d0d38077d0a52d9896389ca60a1a59d3463db586e5fa4 --restart=Never -- sleep 3600
kubectl wait --for=condition=Ready pod/client --timeout=60s
kubectl patch svc reponse -p '{"spec":{"selector":{"app":"reponses"}}}'
Solution
Terminal window
# Diagnosis: the endpoints, then the labels against the selector
kubectl get endpointslice -l kubernetes.io/service-name=reponse
kubectl get pods --show-labels
kubectl get svc reponse -o jsonpath='{.spec.selector}'
# Repair
kubectl patch svc reponse -p '{"spec":{"selector":{"app":"reponse"}}}'
kubectl get endpointslice -l kubernetes.io/service-name=reponse
kubectl exec client -- wget -qO- http://reponse
# What serves the Service: the mode of kube-proxy, then its rules on a node
kubectl -n kube-system get configmap kube-proxy -o yaml | grep -E '^\s+mode:'
docker exec demo-reseau-worker sh -c 'iptables -t nat -S KUBE-SERVICES | head -10'

With a wrong selector, the ENDPOINTS column shows <unset> and wget returns Connection refused: the Service exists, its name resolves, but nobody receives the connection. JSONPath does not add a line break, so {"app":"reponses"} sticks to the next line; compare it with the app=reponse labels of the Pods. After the fix, the three endpoints come back. The kube-proxy ConfigMap declares mode: iptables, the default mode in 1.37, and each -j KUBE-SVC-* rule of the KUBE-SERVICES chain matches one Service port. If the ConfigMap was modified without restarting the Pods, the log is the authority: kubectl -n kube-system logs -l k8s-app=kube-proxy --tail=-1 | grep -i proxier.

On a cluster without kube-proxy such as environment D, these rules do not exist and neither does the kube-proxy ConfigMap. To prove that Cilium serves the Services in its place, run cilium-dbg status | grep KubeProxyReplacement in an agent (the line must be True), then sudo iptables-save | grep -c KUBE-SVC on a node (the output is 0); the lesson on Cilium shows both proofs.


Exercise 6: Add a static entry to CoreDNS, then roll back

A fault in the Corefile stays silent as long as no CoreDNS Pod restarts: back up before you touch anything. Target time: 8 minutes

ContextEnvironment A, namespace ws-dns, client Pod (busybox), coredns ConfigMap of kube-system
TaskMake client resolve vieux.corp.test to 192.0.2.10 with the hosts plugin, without breaking the resolution of cluster names, then restore the original configuration
Validationkubectl -n ws-dns exec client -- nslookup vieux.corp.test returns 192.0.2.10; after the rollback, the two k8s-app=kube-dns Pods are 1/1 Running and the Corefile no longer contains vieux.corp.test
Source lessonCoreDNS, section "How do you change CoreDNS without breaking the cluster's DNS?"
Solution
Terminal window
# 1. Back up the ConfigMap before any change
kubectl -n kube-system get configmap coredns -o yaml > coredns.sauve.yaml
# 2. Insert a hosts block before the kubernetes block, then replace the ConfigMap
kubectl -n kube-system get configmap coredns -o jsonpath='{.data.Corefile}' | awk '/^ kubernetes cluster.local/ {print " hosts {"; print " 192.0.2.10 vieux.corp.test"; print " fallthrough"; print " }"} {print}' > Corefile.hosts
kubectl -n kube-system create configmap coredns --from-file=Corefile=Corefile.hosts --dry-run=client -o yaml | kubectl replace -f -
# 3. Wait for the reload, then test
kubectl -n ws-dns exec client -- nslookup vieux.corp.test
# 4. Roll back: remove resourceVersion, otherwise the replace is refused (Conflict)
sed '/resourceVersion/d' coredns.sauve.yaml | kubectl -n kube-system replace -f -
kubectl -n kube-system get pods -l k8s-app=kube-dns

The change is not immediate: on kind, the first answer arrives between 30 and 89 seconds after the replace, depending on the cluster. Run the nslookup again and allow one to two minutes before concluding to a failure; the log shows [INFO] Reloading then [INFO] Reloading complete. The word fallthrough lets the names absent from the hosts block pass on to the kubernetes plugin.

Replaying the backup as is fails with Conflict: the file carries the resourceVersion of the backup, and Kubernetes refuses to overwrite a more recent version. If you wrote a typo (forwrd instead of forward), the Pods that are already running keep the old configuration and stay Running, but a new Pod loops in CrashLoopBackOff. The log gives the faulty line: kubectl -n kube-system logs -l k8s-app=kube-dns. Restart CoreDNS (kubectl -n kube-system rollout restart deployment coredns) after you have restored the ConfigMap, never before.


Exercise 7: A Pod that never becomes ready

A failing readiness probe restarts nothing: it only takes the Pod out of the traffic, and only the events say why. Target time: 5 minutes

ContextEnvironment A, namespace sondes
Setupkubectl create namespace sondes, then create the sans-route Pod (nginx, readinessProbe httpGet on the path /sante-absente, port 80, periodSeconds: 5)
TaskExplain why the Pod stays 0/1 without restarting, fix the probe, and read the Ready condition of the Pod
Validationkubectl get pod sans-route -n sondes shows 1/1 and the Ready condition is True
Source lessonProbes, section "A readiness probe that fails without restarting anything"
Solution
Terminal window
kubectl apply -n sondes -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: sans-route
spec:
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: /sante-absente
port: 80
periodSeconds: 5
EOF
# Diagnosis: the Unhealthy events
kubectl get pod sans-route -n sondes
kubectl get events -n sondes --field-selector involvedObject.name=sans-route,reason=Unhealthy -o custom-columns=MESSAGE:.message
# Fix: a Pod's probes cannot be edited, so recreate it with the right path
kubectl delete pod sans-route -n sondes
kubectl apply -n sondes -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: sans-route
spec:
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
EOF
kubectl wait --for=condition=Ready pod/sans-route -n sondes --timeout=60s
kubectl get pod -n sondes sans-route -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}'

The Pod stays 0/1 with 0 restarts. Two messages read differently: connection refused dates from before nginx was listening, whereas HTTP probe failed with statuscode: 404 proves that the application answers but that the path does not exist. With the first, look at the startup; with an HTTP code, look at the path. A Pod only accepts a few changes in place, such as the image of a container or the addition of tolerations: a probe is not one of them, so the fix goes through recreating the Pod. A Pod that is not ready stays listed in the EndpointSlice with ready: false, which is enough to take the traffic away from it: the lesson has you read the ready, serving and terminating conditions during a rollout.


Exercise 8: Publish two applications with a Gateway and an HTTPRoute

The Gateway API separates the entry point (the Gateway) from the routing rules (the HTTPRoute), and the state is read in the conditions. Target time: 8 minutes

ContextEnvironment B, namespace ws-gateway, Deployments and Services app-a and app-b of the lesson's apps.yaml file, Traefik installed
TaskCreate a web Gateway of class traefik that listens over HTTP on port 80 and only accepts routes from its own namespace, then a demo HTTPRoute that sends /a to app-a and /b to app-b for the host demo.test
ValidationThe Gateway is PROGRAMMED True, the route has the conditions Accepted=True and ResolvedRefs=True, and curl -H 'Host: demo.test' http://localhost:8080/a/ returns application A, /b/ returns application B
Source lessonGateway API, sections "Gateway" and "HTTPRoute"
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: web
namespace: ws-gateway
spec:
gatewayClassName: traefik
listeners:
- name: http
port: 80
protocol: HTTP
allowedRoutes:
namespaces:
from: Same
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: demo
namespace: ws-gateway
spec:
parentRefs:
- name: web
hostnames:
- demo.test
rules:
- matches:
- path:
type: PathPrefix
value: /a
backendRefs:
- name: app-a
port: 80
- matches:
- path:
type: PathPrefix
value: /b
backendRefs:
- name: app-b
port: 80
EOF
kubectl -n ws-gateway wait --for=condition=Programmed gateway/web --timeout=120s
kubectl -n ws-gateway get httproute demo -o jsonpath='{range .status.parents[*].conditions[*]}{.type}={.status} ({.reason}){"\n"}{end}'
curl -sS -m 5 -H 'Host: demo.test' http://localhost:8080/a/
curl -sS -m 5 -H 'Host: demo.test' http://localhost:8080/b/

The listener port must match an entry point of Traefik, here the web entrypoint on 80: with another port, the Gateway is registered by the API but never programmed. The ADDRESS column stays empty with Traefik and does not signal a failure. kubectl get httproute only shows the hosts: Accepted says that the route is attached, ResolvedRefs that its backends exist, and only these two fields tell a served route from an ignored one. Ports 8080 and 8443 are the ones that kind-expo.yaml publishes on the workstation.


Domain 3, Advanced Traffic Management (20%)

Each of the four exercises in this domain asks for a configuration object to write correctly the first time, then for a proof taken at the destination: the server that sees the source address, the router that receives the route, the client that reads the distribution. An object accepted by the API never proves that the traffic follows.


Exercise 9: Route inference requests with an InferencePool

An ordinary Service spreads requests without looking at the load of the replicas; the InferencePool hands the choice to an endpoint picker that reads their metrics. Target time: 8 minutes

ContextEnvironment E with the Inference Extension v1.5.0, namespace inference: Deployments modele-libre (2 replicas) and modele-sature (1 replica), all app: modele, and picker selecteur on port 9002, deployed by the lesson's lab, which creates neither the pool, nor the Gateway, nor the route: the picker stays not ready as long as the pool does not exist
TaskDeclare the InferencePool pool-modele in front of the replicas, a passerelle-ia Gateway (class istio) and a route-modele HTTPRoute that points to the pool, then send 30 requests
ValidationThe Gateway is PROGRAMMED True, the selecteur Deployment is ready, and out of 30 requests the saturated replica receives at most 3
Source lessonRouting LLM inference traffic with Istio and InferencePool, section "How do you declare the InferencePool and the route?"
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: inference.networking.k8s.io/v1
kind: InferencePool
metadata:
name: pool-modele
namespace: inference
spec:
selector:
matchLabels:
app: modele
targetPorts:
- number: 8000
endpointPickerRef:
name: selecteur
port:
number: 9002
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: passerelle-ia
namespace: inference
annotations:
networking.istio.io/service-type: ClusterIP
spec:
gatewayClassName: istio
listeners:
- name: http
port: 80
protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: route-modele
namespace: inference
spec:
parentRefs:
- name: passerelle-ia
sectionName: http
rules:
- backendRefs:
- group: inference.networking.k8s.io
kind: InferencePool
name: pool-modele
EOF
kubectl -n inference rollout status deploy/selecteur
kubectl -n inference get inferencepool,gateway,httproute
kubectl -n inference rollout status deploy/passerelle-ia-istio
IP=$(kubectl -n inference get svc -l gateway.networking.k8s.io/gateway-name=passerelle-ia -o jsonpath='{.items[0].spec.clusterIP}'); for i in $(seq 1 30); do curl -s -o /dev/null -D - --max-time 20 -H 'Content-Type: application/json' -d "{\"model\":\"meta-llama/Llama-3.1-8B-Instruct\",\"prompt\":\"Pool $i $(date +%s%N)\",\"max_tokens\":8}" http://$IP/v1/completions | tr -d '\r' | grep -i '^x-inference-pod:'; done | sort | uniq -c

The first two rollout status commands wait for the picker and the Gateway to be ready before the first request. The pool takes the three replicas through app: modele, the saturated one included: the picker is what avoids it, by reading its metrics. The text of each request changes, because the picker may favor the replica that has already seen the same beginning of text. Read the last command: it counts the requests per replica, and the saturated one receives at most 3, or does not appear at all (20 and 10 requests on the two free replicas in the lesson, your distribution will differ). The x-inference-pod header is set by the simulator on every response, even when called directly: it proves nothing on its own, it is the number of requests received by the saturated replica that proves it. If the route is accepted but ResolvedRefs=False with the reason InvalidKind, the ENABLE_GATEWAY_API_INFERENCE_EXTENSION variable of istiod is false.


Exercise 10: Announce a LoadBalancer Service to a router over BGP

Without a cloud, a LoadBalancer Service has no address: Cilium draws it from a pool, then announces it to the router over BGP. Target time: 10 minutes

ContextEnvironment D with the Cilium BGP control plane enabled and an FRR router outside the cluster (10.10.50.200, ASN 65000, container ckne-frr)
TaskDeclare the four BGP objects (nodes ASN 65001 carrying the label bgp=actif, peer, advertisement, pool 172.30.0.0/28), label the three nodes, then expose a web Deployment as LoadBalancer and announce its address
Validationkubectl -n bgp-demo get service web shows an EXTERNAL-IP from the pool, show bgp ipv4 unicast on the router contains the address as a /32, cilium bgp peers shows established for the three nodes, and a wget run from the router returns the title Welcome to nginx!
Source lessonAnnounce Services to the network with BGP and Cilium
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: cilium.io/v2
kind: CiliumBGPClusterConfig
metadata:
name: vers-routeur-frr
spec:
nodeSelector:
matchLabels:
bgp: actif
bgpInstances:
- name: instance-65001
localASN: 65001
peers:
- name: routeur-frr
peerASN: 65000
peerAddress: 10.10.50.200
peerConfigRef:
name: pair-frr
---
apiVersion: cilium.io/v2
kind: CiliumBGPPeerConfig
metadata:
name: pair-frr
spec:
families:
- afi: ipv4
safi: unicast
advertisements:
matchLabels:
annonce: frr
---
apiVersion: cilium.io/v2
kind: CiliumBGPAdvertisement
metadata:
name: annonces-frr
labels:
annonce: frr
spec:
advertisements:
- advertisementType: PodCIDR
- advertisementType: Service
service:
addresses:
- LoadBalancerIP
selector:
matchLabels:
annonce-bgp: oui
---
apiVersion: cilium.io/v2
kind: CiliumLoadBalancerIPPool
metadata:
name: pool-bgp
spec:
blocks:
- cidr: 172.30.0.0/28
EOF
kubectl label node net-cp.lab net-w1.lab net-w2.lab bgp=actif --overwrite
kubectl create namespace bgp-demo
kubectl -n bgp-demo create deployment web --image=nginx:1.27@sha256:6784fb0834aa7dbbe12e3d7471e69c290df3e6ba810dc38b34ae33d3c1c05f7d
kubectl -n bgp-demo expose deployment web --port=80 --type=LoadBalancer
kubectl -n bgp-demo label service web annonce-bgp=oui
kubectl -n bgp-demo rollout status deployment/web --timeout=120s
# BGP sessions come up 20 to 25 s after the objects are created: wait, without exceeding 2 min
timeout 120 sh -c "until kubectl -n bgp-demo get service web -o jsonpath='{.status.loadBalancer.ingress[0].ip}' | grep -q 172.30; do sleep 2; done"
timeout 120 sh -c 'until [ "$(cilium bgp peers | grep -c established)" -eq 3 ]; do sleep 2; done'
kubectl -n bgp-demo get service web
docker exec ckne-frr vtysh -c 'show bgp summary'
cilium bgp peers
docker exec ckne-frr vtysh -c 'show bgp ipv4 unicast'
docker exec ckne-frr sh -c 'wget -qO- -T 5 http://172.30.0.0/ | grep -o "<title>.*</title>"'

The two timeout 120 sh -c 'until …' commands wait, two minutes at most, for the Service to receive its address and then for the three BGP sessions to be established: read too early, the outputs that follow would be incomplete. The objects are tied together by labels that you must copy exactly: the nodeSelector selects bgp: actif, the peer points to the annonce: frr advertisements, the advertisement selects the Services annonce-bgp: oui. A mistyped label cuts the link with no error message. Without the annonce-bgp=oui label, the Service receives an address from the pool but is not announced. The Service is announced as a /32, and its route arrives from the three nodes. The address 172.30.0.0, the first of the block, is used as is in the test. Check the sessions on both sides: show bgp summary on the router, and cilium bgp peers on the cluster side, where the Session State column must read established for each node.


Exercise 11: Send a Pod out through a chosen node address

An egress gateway gives a single Pod a known source address, and the proof is taken at the recipient. Target time: 8 minutes

ContextEnvironment D with egressGateway.enabled=true and bpf.masquerade=true, namespace egress-demo, Pods sortie-controlee (app: sortie-controlee) and autre on net-w1, witness server at address 10.10.50.1 on port 8090
TaskDesignate net-w2.lab as the exit node with a label, write the CiliumEgressGatewayPolicy that sends sortie-controlee out to 10.10.50.1/32 through that node, and prove that only that Pod is targeted
ValidationThe witness sees the source of net-w2 for sortie-controlee and that of net-w1 for autre, and cilium-dbg bpf egress list shows the address of the targeted Pod with the Gateway IP column of net-w2
Source lessonSend a Pod's traffic out through an egress gateway
Solution
Terminal window
kubectl label node net-w2.lab egress-gateway=true --overwrite
kubectl apply -f - <<'EOF'
apiVersion: cilium.io/v2
kind: CiliumEgressGatewayPolicy
metadata:
name: sortie-par-net-w2
spec:
selectors:
- podSelector:
matchLabels:
app: sortie-controlee
io.kubernetes.pod.namespace: egress-demo
destinationCIDRs:
- 10.10.50.1/32
egressGateway:
nodeSelector:
matchLabels:
egress-gateway: "true"
interface: enp1s0
EOF
kubectl -n egress-demo exec sortie-controlee -- wget -qO- -T 5 http://10.10.50.1:8090/vise
kubectl -n egress-demo exec autre -- wget -qO- -T 5 http://10.10.50.1:8090/non-vise
kubectl -n kube-system get pods -l k8s-app=cilium --field-selector spec.nodeName=net-w1.lab -o name
kubectl -n kube-system exec pod/<net-w1-agent> -c cilium-agent -- cilium-dbg bpf egress list

In the lesson, the targeted Pod arrives with 10.10.50.16, the address of net-w2, and autre, on the same node but without the label, with 10.10.50.15: the policy applies Pod by Pod. The io.kubernetes.pod.namespace label avoids targeting a Pod with the same label in another namespace, and "true" is written between quotes because a label is a string. The interface field names the network card of the exit node, enp1s0 on the lesson's machines. If no node carries the label, the targeted traffic is dropped, it is not sent out by the node of the Pod. In the BPF table, do not take Egress IP at 0.0.0.0 for a failure, this column is only filled on the gateway; look at Gateway IP.


A global Service gathers the Pods of two clusters under one name, and keeps answering when one of the two has no Pod left. Target time: 10 minutes

ContextEnvironment F, two Cilium clusters with ClusterMesh enabled but not connected, contexts cluster-1 and cluster-2
TaskLink the clusters with the cilium CLI, deploy in each one a global echo Service in the mesh-demo namespace, show that responses come from both clusters, then empty cluster-1 of its Pods and observe that the Service still answers
Validationcilium clustermesh status ends with cluster-2: 1/1 configured, 1/1 connected, 12 calls from cluster-1 return responses from both clusters, and 8 calls after scale ... --replicas=0 all return reponse-de-cluster-2
Source lessonLink two clusters with Cilium ClusterMesh
Solution
Terminal window
cilium clustermesh connect --context cluster-1 --destination-context cluster-2
cilium clustermesh status --context cluster-1 --wait --wait-duration 5m
# echo.yaml: the cluster-1 version (cluster-2 replaces reponse-de-cluster-1 with reponse-de-cluster-2)
cat > echo.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata: {name: echo, namespace: mesh-demo}
spec:
replicas: 1
selector: {matchLabels: {app: echo}}
template:
metadata: {labels: {app: echo}}
spec:
containers:
- name: c
image: busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec
command: [sh, -c, 'echo reponse-de-cluster-1 > /tmp/index.html; httpd -f -p 8080 -h /tmp']
---
apiVersion: v1
kind: Service
metadata:
name: echo
namespace: mesh-demo
annotations:
service.cilium.io/global: "true"
spec:
selector: {app: echo}
ports: [{port: 80, targetPort: 8080}]
EOF
kubectl --context cluster-1 create namespace mesh-demo
kubectl --context cluster-1 apply -f echo.yaml
kubectl --context cluster-2 create namespace mesh-demo
sed 's/reponse-de-cluster-1/reponse-de-cluster-2/' echo.yaml | kubectl --context cluster-2 apply -f -
kubectl --context cluster-1 -n mesh-demo rollout status deploy/echo --timeout=120s
kubectl --context cluster-2 -n mesh-demo rollout status deploy/echo --timeout=120s
kubectl --context cluster-1 -n mesh-demo run client --image=busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec --restart=Never -- sleep 3600
kubectl --context cluster-1 -n mesh-demo wait --for=condition=Ready pod/client --timeout=120s
# "connected" does not yet guarantee that data flows: wait for a first answer from cluster-2, 2 min at most
timeout 120 sh -c 'until kubectl --context cluster-1 -n mesh-demo exec client -- wget -qO- -T 3 http://echo.mesh-demo/ | grep -q cluster-2; do sleep 2; done'
for i in $(seq 1 12); do kubectl --context cluster-1 -n mesh-demo exec client -- wget -qO- -T 3 http://echo.mesh-demo/; done | sort | uniq -c
kubectl --context cluster-1 -n mesh-demo scale deploy/echo --replicas=0
sleep 10
for i in $(seq 1 8); do kubectl --context cluster-1 -n mesh-demo exec client -- wget -qO- -T 3 http://echo.mesh-demo/; done | sort | uniq -c

The link takes between 20 and 30 seconds to establish: the ⌛ lines of --wait are waits, not errors. Data flow follows with a little delay: right after "connected", calls routed to cluster-2 can still end in wget: download timed out, hence the timeout 120 sh -c 'until …' command, which waits for a first answer from cluster-2 for two minutes at most before the series. A Service is global when it carries the annotation service.cilium.io/global: "true", with the same name and the same namespace in each cluster, the annotation being set in each of them. The lesson's series of 12 calls returns 8 responses from cluster-1 and 4 from cluster-2: a series this short does not set a distribution rule, it only proves that both clusters answer. Without the annotation on the cluster-1 side, the same request becomes local again: kubectl --context cluster-1 -n mesh-demo annotate service echo service.cilium.io/global- gives 8 responses from cluster-1. Then restore one replica with scale deploy/echo --replicas=1.


Domain 4, Network Security and Policy (25%)

This domain weighs a quarter of the blueprint. The four exercises go from the NetworkPolicy to mTLS and rest on the same habit: prove both what gets through and what is refused, with a witness client that is not targeted.


Exercise 13: Isolate a database on ingress and egress, except for the backend and DNS

A policy without rules allows nothing, and policies add up: you close first, then open flow by flow. Target time: 10 minutes

ContextEnvironment A, the four Pods of the lesson (np-base.yaml file): db (label app=db, page db-ok on port 80) behind the db Service (port 5432, targetPort 80), backend (role=backend) and frontend (role=frontend) in ws-np, intrus (role=backend) in ws-np-autre
TaskClose db on ingress and egress, allow on ingress only the role=backend Pods of the namespace, on the container port, and allow on egress only DNS to the CoreDNS Pods
Validationbackend gets db-ok, frontend and intrus time out, db resolves kubernetes.default.svc.cluster.local, and port 8080 of a CoreDNS Pod stays unreachable from db
Source lessonNetworkPolicies, sections "Default deny ingress", "Allow one specific flow", "Default deny egress" and "Allow DNS"
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: db-deny-all
namespace: ws-np
spec:
podSelector:
matchLabels:
app: db
policyTypes:
- Ingress
- Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: db-allow-backend
namespace: ws-np
spec:
podSelector:
matchLabels:
app: db
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
role: backend
ports:
- protocol: TCP
port: 80
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: db-allow-dns
namespace: ws-np
spec:
podSelector:
matchLabels:
app: db
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
EOF
for p in ws-np/backend ws-np/frontend ws-np-autre/intrus; do ns=${p%/*}; pod=${p#*/}; echo "--- $pod"; kubectl -n $ns exec $pod -- wget -qO- -T 3 http://db.ws-np.svc.cluster.local:5432; echo "rc=$?"; done
kubectl -n ws-np exec db -- nslookup kubernetes.default.svc.cluster.local; echo "rc=$?"
IP=$(kubectl -n kube-system get pods -l k8s-app=kube-dns -o jsonpath='{.items[0].status.podIP}')
kubectl -n ws-np exec db -- wget -qO- -T 3 http://$IP:8080/health; echo "rc=$?"

The port field of a rule is the container's, that is the targetPort of the Service (80), never the published port (5432): with port: 5432, the policy is accepted without error and backend itself no longer reaches the database. intrus carries the label role=backend and still times out, because a podSelector alone designates the Pods of the policy's namespace. Without the DNS rule, nslookup waits 5 seconds then returns connection timed out; no servers could be reached. The last command must fail with a timeout: opening DNS opens nothing else. A refusal on ingress shows up as a timeout, not as a refused connection.


Exercise 14: Filter the method and the path with an L7 policy

A NetworkPolicy reasons in addresses and ports; a CiliumNetworkPolicy can limit HTTP requests to one method and one path. Target time: 8 minutes

ContextEnvironment D, namespace vitrine: Pods app=vitrine behind the vitrine Service (port 80, container on port 5678), Cilium L7 proxy active
Setupkubectl -n vitrine run client --image=curlimages/curl:8.17.0@sha256:935d9100e9ba842cdb060de42472c7ca90cfe9a7c96e4dacb55e79e560b3ff40 --labels=app=client --restart=Never --command -- sleep 36000, and the same command for intrus with --labels=app=intrus
TaskAllow toward vitrine only the app=client Pods, on port 5678, and for them only GET on the path /
ValidationGET / from client returns 200, POST / and GET /admin return 403, and intrus times out (code 000, exit 28)
Source lessonServe a Gateway and filter at L7 with Cilium, section "How do you filter the HTTP method and path with a CiliumNetworkPolicy?"
Solution
Terminal window
kubectl apply -f - <<'EOF'
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: /
EOF
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/

There are two kinds of refusal. For client, the connection is accepted and the proxy refuses the request: 403 and the text Access denied. For intrus, no rule allows it, the connection is cut before any HTTP request and curl returns 000 with exit code 28. The port in the rule is the application's (5678), not the Service's. method and path are regular expressions. The Valid state of the policy (kubectl -n vitrine get cnp vitrine-get-seulement -o jsonpath='{.status.conditions}') says that Cilium understood it, not that it does what you expect: the proof is in the codes.

If a Cilium Gateway also serves vitrine, this policy cuts its traffic: the reserved ingress identity must be allowed by a second rule fromEntities: [ingress] with the same http rules, as the lesson shows.


Exercise 15: Serve a Gateway over HTTPS with a cert-manager certificate

The HTTPS listener does not make its certificate: it reads a TLS Secret from its own namespace, which cert-manager writes. Target time: 8 minutes

ContextEnvironment E, namespace vitrine with a vitrine Service (port 80), ClusterIssuer named ca-formation already installed
TaskAsk cert-manager for a certificate for vitrine.formation.test in the namespace of the Gateway, declare an Istio vitrine Gateway with an HTTPS listener that terminates TLS with that Secret, and a vitrine HTTPRoute that targets that listener
Validationkubectl -n vitrine get certificate shows READY True, the Gateway is PROGRAMMED True, and the https listener has its Accepted, Programmed and ResolvedRefs conditions at True and Conflicted at False
Source lessonGateway API over HTTPS: serving a cert-manager certificate
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: vitrine-tls
namespace: vitrine
spec:
secretName: vitrine-tls
dnsNames:
- vitrine.formation.test
issuerRef:
group: cert-manager.io
kind: ClusterIssuer
name: ca-formation
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: vitrine
namespace: vitrine
annotations:
networking.istio.io/service-type: ClusterIP
spec:
gatewayClassName: istio
listeners:
- name: https
port: 443
protocol: HTTPS
hostname: vitrine.formation.test
tls:
mode: Terminate
certificateRefs:
- kind: Secret
name: vitrine-tls
allowedRoutes:
namespaces:
from: Same
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: vitrine
namespace: vitrine
spec:
parentRefs:
- name: vitrine
sectionName: https
hostnames:
- vitrine.formation.test
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: vitrine
port: 80
EOF
kubectl -n vitrine get certificate
kubectl -n vitrine get gateway vitrine
kubectl -n vitrine get gateway vitrine -o yaml

The Certificate is created in the namespace of the Gateway, and its secretName is the one that certificateRefs designates. The kind: ClusterIssuer field matters: an Issuer of the same name does not exist and cert-manager does not look for it in your place. With tls.mode: Terminate, the Gateway decrypts the TLS and sends the request to the Service over HTTP, without re-encrypting it. The annotation networking.istio.io/service-type: ClusterIP is for a cluster without a load balancer; otherwise the Gateway stays unprogrammed. The conditions of the Gateway do not describe its listener: read status.listeners[].conditions in the YAML output, where Conflicted=False is the only field for which False is the good state. A Secret from another namespace also needs a ReferenceGrant, which the lesson details.


Exercise 16: Require mTLS and allow only one identity

The STRICT mode imposes encryption and identity; the AuthorizationPolicy then decides who may call what. Target time: 8 minutes

ContextEnvironment G, with in the production namespace the Pods frontend and intrus (curl container, two different ServiceAccounts) and the api-server service on port 8080, as in the lesson
TaskImpose STRICT mTLS on the whole mesh, allow toward api-server only the frontend ServiceAccount, then prove that a Pod without a proxy is rejected
Validationfrontend gets HTTP 200, intrus gets HTTP 403 with RBAC: access denied, and a Pod started in a namespace without injection fails with HTTP code 000 and exit code 56
Source lessonPod-to-pod mTLS, sections "PeerAuthentication: enforce mTLS" and "AuthorizationPolicy: identity-based access control"
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system
spec:
mtls:
mode: STRICT
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: api-server-access
namespace: production
spec:
selector:
matchLabels:
app: api-server
action: ALLOW
rules:
- from:
- source:
principals:
- "cluster.local/ns/production/sa/frontend"
EOF
timeout 120 sh -c "until kubectl -n production exec intrus -c curl -- curl -s -o /dev/null -w '%{http_code}' --max-time 5 http://api-server.production.svc.cluster.local:8080/ | grep -q 403; do sleep 2; done"
kubectl -n production exec frontend -c curl -- curl -s -o /dev/null -w 'HTTP %{http_code}\n' --max-time 5 http://api-server.production.svc.cluster.local:8080/
kubectl -n production exec intrus -c curl -- curl -s -w '\nHTTP %{http_code}\n' --max-time 5 http://api-server.production.svc.cluster.local:8080/
kubectl create namespace no-mesh
kubectl run test-clear --image=curlimages/curl:8.23.0@sha256:3fb7e13e5d179a845c97d78204f3f1064d1907037f26a3ebf91710571151fd93 --rm -it --restart=Never -n no-mesh \
-- curl -s -o /dev/null -w "HTTP %{http_code}\n" --max-time 5 http://api-server.production.svc.cluster.local:8080

The root namespace istio-system makes the default policy a rule for the whole mesh; the most specific one wins (workload, then namespace, then mesh). The effect of a policy is not immediate: istiod pushes it to the proxies within a few seconds, hence the until loop, bounded to two minutes by timeout 120, which waits for the 403 of intrus before testing. The source.principals field reads the identity of the client's certificate, in the format <domain>/ns/<namespace>/sa/<service-account>: it assumes mTLS, a clear-text request carries no identity. The refusal therefore comes from the identity, not from the address. For the Pod without a proxy, the TCP connection is established but the TLS handshake fails, hence HTTP 000; exit code 56 is read with echo $? right afterwards, because kubectl takes over that of curl. A default deny (action: ALLOW without rules) refuses everything, even frontend.


Domain 5, Observability (15%)

The two exercises of this domain start from a real symptom, a client that no longer gets an answer, and ask you to find the refused flow without removing the policy, then to count it and keep a trace of it. Only one agent sees the ingress refusal: the one on the node that hosts the called Pod.


Exercise 17: Find the refused client with Hubble

A policy refusal leaves no message on the client side: the connection times out, and only the agent of the right node knows why. Target time: 6 minutes

ContextEnvironment D, namespace magasin: the api API runs on net-w1, three clients vitrine, panier and compta call it from net-w2, the api-entrant NetworkPolicy protects the API
TaskFind which client is refused and why, without removing the policy
ValidationYou name the source Pod (magasin/vitrine), the called Pod (magasin/api), the verdict DROPPED and the reason POLICY_DENIED
Source lessonHubble, section "How do you find the flow that a NetworkPolicy refuses?"
Solution
Terminal window
# Which rule applies, and on which node the API runs
kubectl -n magasin get networkpolicy api-entrant -o yaml
kubectl -n magasin get pods -o wide
kubectl -n kube-system get pods -l k8s-app=cilium -o wide
# The refusals of the last minute, read on the agent of the API's node
kubectl -n kube-system exec <net-w1-agent> -c cilium-agent -- \
hubble observe --namespace magasin --verdict DROPPED --since 1m --last 5
# The exact reason, in JSON
kubectl -n kube-system exec <net-w1-agent> -c cilium-agent -- \
hubble observe --namespace magasin --verdict DROPPED --since 1m --last 1 -o json

An ingress policy applies where the destination Pod lives: query the agent of the API's node, here net-w1, otherwise the list comes back empty although the refusals exist. Each refusal appears on two lines, policy-verdict:none INGRESS DENIED (no ingress rule allows the flow) then Policy denied DROPPED (the packet is dropped), repeated one second apart because the client retries its SYN. The drop_reason_desc field is POLICY_DENIED for a policy refusal. The --since 1m option rules out the older flows of the buffer, which could point to another client.


Exercise 18: Count refusals per Pod and keep a trace of them

The default metric says that a packet is refused, not who sent it: a context in the metric name adds the Pod, and an export writes the refusals to a file. Target time: 10 minutes

ContextEnvironment D, scenario of exercise 17 still in place, Cilium installed with Helm
TaskMake hubble_drop_total name the Pods, export only the refused flows to a log on the node, then read the metric and the log; also read the DNS metrics of CoreDNS
Validationhubble_drop_total carries source="magasin/vitrine", destination="magasin/api" and reason="POLICY_DENIED" with a value that increases, the events.log log contains the refusals in JSON, and coredns_dns_requests_total answers
Source lessonHubble, sections "How do you count refusals with metrics?" and "How do you keep a trace of refusals for audit?", and CoreDNS, section "Metrics and monitoring"
Solution
Terminal window
cat > hubble-audit.yaml <<'EOF'
hubble:
metrics:
enabled:
- dns
- drop:sourceContext=pod;destinationContext=pod
- tcp
- flow
- port-distribution
- icmp
- httpV2
export:
static:
enabled: true
filePath: /var/run/cilium/hubble/events.log
allowList:
- '{"verdict":["DROPPED"]}'
EOF
helm upgrade cilium cilium/cilium --version 1.20.5 --namespace kube-system \
--reuse-values -f hubble-audit.yaml
kubectl -n kube-system rollout status ds/cilium
# The metric, on the API's node (address: kubectl get node net-w1.lab -o wide)
curl -s http://<net-w1-address>:9965/metrics | grep hubble_drop_total
# The audit log of the same node. The upgrade replaced the cilium Pods:
# get the agent name now, not the one from exercise 17
AGENT=$(kubectl -n kube-system get pods -l k8s-app=cilium \
--field-selector spec.nodeName=net-w1.lab -o name)
kubectl -n kube-system exec "$AGENT" -c cilium-agent -- \
tail -2 /var/run/cilium/hubble/events.log
# The DNS metrics of CoreDNS, without a collector
kubectl -n kube-system port-forward svc/kube-dns 9153:9153 &
sleep 3
curl -s http://localhost:9153/metrics | grep -m5 coredns_dns_requests_total
kill %1

The upgrade replaces the cilium Pods: get the agent name afterwards, the one from exercise 17 no longer exists. A file passed with -f replaces a list instead of completing it: the file therefore repeats the whole hubble.metrics.enabled list, with drop modified. Without the context, the hubble_drop_total series carries the reason and the protocol, not the Pod. The value of the series is a counter that only increases as long as the client retries: reading it again shortly afterwards gives a larger value, which proves that the refusal is still in place. The log answers three audit questions, when (time), who (source.pod_name) and why (drop_reason_desc), and each node writes its own file. Treat it as sensitive data: it carries Pod names and labels.


Summary of target times

This table gives the target time of each exercise so you can plan your practice sessions. The last column says whether the exercise runs with the environment alone (Yes) or also needs a setup from the lesson, such as a router, a second cluster or an installed tool (No).

#ExerciseDomainEnv.TimeStandalone
1Read the address rangesCore Infrastructure and CNIA4 minYes
2Repair a node without a CNI configurationCore Infrastructure and CNIA8 minYes
3Capture a Pod's trafficCore Infrastructure and CNIC8 minNo (prepared failure)
4Second interface with MultusCore Infrastructure and CNID8 minNo (Multus)
5Service without endpoints, and kube-proxyService Networking and DNSA8 minYes
6CoreDNS static entryService Networking and DNSA8 minNo (client Pod of the lesson)
7Failing readiness probeService Networking and DNSA5 minYes
8Gateway and HTTPRouteService Networking and DNSB8 minNo (apps.yaml of the lesson)
9InferencePoolAdvanced Traffic ManagementE8 minNo (lab)
10BGP announcement of a ServiceAdvanced Traffic ManagementD10 minNo (FRR router)
11Egress gatewayAdvanced Traffic ManagementD8 minNo (egress enabled)
12ClusterMesh global ServiceAdvanced Traffic ManagementF10 minNo (two clusters)
13NetworkPolicy ingress, egress and DNSNetwork Security and PolicyA10 minNo (np-base.yaml of the lesson)
14Cilium L7 policyNetwork Security and PolicyD8 minNo (vitrine application)
15HTTPS Gateway and cert-managerNetwork Security and PolicyE8 minNo (cert-manager)
16STRICT mTLS and AuthorizationPolicyNetwork Security and PolicyG8 minNo (Istio sidecar)
17Find a refusal with HubbleObservabilityD6 minNo (magasin scenario)
18Refusal metrics and logObservabilityD10 minNo (exercise 17)

The times add up to about 143 minutes for the 18 exercises: 28 minutes for the first domain, 29 for the second, 36 for the third, 34 for the fourth and 16 for the last. The CKNE exam lasts 2 hours: do not chain them in one go. Work domain by domain, starting with Service Networking and DNS and Network Security and Policy, which weigh half of the blueprint.

These times are orders of magnitude for a cluster that is already ready: note your own, and redo while the topic is fresh the exercises that exceed twice the target time. Environments C to G need a preparation time that the table does not count.


Cleanup

Reset the cluster between two exercises, otherwise the objects of one distort the result of the next. These commands follow the order of the environments.

Terminal window
# Environment A
kubectl delete namespace ws-podnet ws-dns ws-np ws-np-autre sondes
kubectl delete deployment reponse
kubectl delete service reponse
kubectl delete pod client
# Exercise 6: if you want to go back to the original CoreDNS configuration
sed '/resourceVersion/d' coredns.sauve.yaml | kubectl -n kube-system replace -f -
# End of the series: destroy the kind cluster
kind delete cluster --name demo-reseau
# Environment B
kubectl delete namespace ws-gateway
# Environment C (exercise 3)
rm /tmp/perte.pcap
# Environment D
kubectl delete namespace multus-demo bgp-demo egress-demo
kubectl delete ciliumbgpclusterconfig vers-routeur-frr
kubectl delete ciliumbgppeerconfig pair-frr
kubectl delete ciliumbgpadvertisement annonces-frr
kubectl delete ciliumloadbalancerippool pool-bgp
kubectl label node net-cp.lab net-w1.lab net-w2.lab bgp-
kubectl delete ciliumegressgatewaypolicies sortie-par-net-w2
kubectl label node net-w2.lab egress-gateway-
kubectl -n vitrine delete cnp vitrine-get-seulement
kubectl -n vitrine delete pod client intrus
# Environment E
kubectl -n inference delete httproute route-modele
kubectl -n inference delete gateway passerelle-ia
kubectl -n inference delete inferencepool pool-modele
kubectl -n vitrine delete httproute vitrine
kubectl -n vitrine delete gateway vitrine
kubectl -n vitrine delete certificate vitrine-tls
# Environment G
kubectl -n production delete authorizationpolicy api-server-access
kubectl -n istio-system delete peerauthentication default
kubectl delete namespace no-mesh
# Environment F
kubectl --context cluster-1 delete namespace mesh-demo
kubectl --context cluster-2 delete namespace mesh-demo

Two exercises leave a state that survives the deletion of the objects. Exercise 18 keeps the export of the refusals and the context of the metric until a new helm upgrade puts back the original hubble.metrics.enabled list (with drop alone) and sets hubble.export.static.enabled to false. The ClusterMesh link of exercise 12 stays in place: recreate both clusters to replay the exercise from the unconnected state.


Put it into practice

The capstone chains three networking skills across two clusters, one per site, with no hints. You link them with Cilium ClusterMesh (see ClusterMesh), you announce a Service to the network team's router (see Announce Services to the network with BGP and Cilium), then you serve the shop over HTTPS with a Cilium Gateway and cert-manager (see Gateway API over HTTPS and Serve a Gateway and filter at L7 with Cilium). The validation checks the state of the clusters, never the commands you typed, and its three requirements are blocking: the passing threshold is 70.

The first requirement: the shop answers from both sites and keeps answering when site 1 has no replica left. The second: a site 1 Service receives an address from the pool, announced over BGP. The router learns it by itself and can reach the shop, while a Service without the announcement label does not appear on it. The third: the shop is served over HTTPS under its public name, with a certificate that cert-manager issues from the internal authority provided, and plain HTTP is redirected to HTTPS. Plan for about 75 minutes.


Key takeaways

  1. Bound every network test with a timeout: an immediate refusal means that no program is listening, a timeout that a packet is lost on the way.
  2. A Service without endpoints is created without error: always read the EndpointSlice, then the kube-proxy ConfigMap if the rules are missing.
  3. Keep a backup before you modify the Corefile, remove resourceVersion to replay it, and only restart CoreDNS after you have restored the ConfigMap.
  4. The port of a NetworkPolicy is the container's; policies add up, and a refusal on ingress shows up as a timeout.
  5. An HTTPRoute is read in its Accepted and ResolvedRefs conditions, a Gateway in Programmed, and an HTTPS listener in status.listeners[].conditions.
  6. A traffic proof is taken at the destination: the source seen by the server for egress, the BGP table of the router, the distribution of the responses for a global Service.
  7. Only one Cilium agent sees an ingress refusal, the one on the node of the called Pod: read hubble observe --verdict DROPPED and drop_reason_desc on that one.
  8. Reset the cluster between two exercises and note your own times: the ones on this page are orders of magnitude.

Test your knowledge

Eight questions, six of them drawn at random, check what these exercises make you do: read a network failure, repair a CNI, fix a Service, modify CoreDNS, write a NetworkPolicy or an L7 policy, announce a Service, link two clusters and audit the refusals.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% 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