CKA: Services and Networking
20% of the CKA exam, 6 competencies. Back to the CKA overview.
Each competency lists what to know and the official documentation to read, then a demo you can run. Demos run on the demo lab, a throwaway kind cluster on your own machine; set it up once before you start.
Understand connectivity between Pods
Section titled “Understand connectivity between Pods”Know
- Pod-to-pod traffic is routed by the CNI plugin with no NAT. Pod IPs change, which is why Services exist.
Read
Demo: Pod to pod, across nodes, without NAT
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-podnetkubectl config set-context --current --namespace=cka-podnet -
Run one server pod on each worker.
Terminal window for n in kind-worker kind-worker2; dokubectl run srv-$n --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 --overrides="{\"spec\":{\"nodeName\":\"$n\"}}" -- netexec --http-port=8080donekubectl wait --for=condition=Ready pod --all --timeout=120skubectl get pods -o wide -
Call one pod’s IP from the other and ask who called.
Terminal window IP2=$(kubectl get pod srv-kind-worker2 -o jsonpath='{.status.podIP}')kubectl exec srv-kind-worker -- wget -qO- -T 3 http://$IP2:8080/clientip; echokubectl get pod srv-kind-worker -o jsonpath='{.status.podIP}{"\n"}' -
See how the node routes it.
Terminal window docker exec kind-worker ip route | grep -v default
What you should see: /clientip reports the first pod’s own IP, not a node IP: no NAT between pods. The node’s routing table has a route per other node’s pod CIDR, which is how kindnet implements the Kubernetes network model.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace cka-podnetDefine and enforce Network Policies
Section titled “Define and enforce Network Policies”Know
- A pod selected by any policy becomes isolated for that direction; policies only add allows. Egress default-deny blocks DNS unless you allow it.
- Enforcement needs a CNI that supports NetworkPolicy.
Read
Demo: Default deny, then allow one client
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-netpolkubectl config set-context --current --namespace=cka-netpol -
A server and two clients. Everything can talk at first.
Terminal window kubectl create deployment db --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- /agnhost netexec --http-port=8080kubectl expose deployment db --port=8080kubectl rollout status deployment/dbfor c in api other; do kubectl run $c --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 --labels=role=$c -- sleep 3600; donekubectl wait --for=condition=Ready pod/api pod/other --timeout=120skubectl exec other -- wget -qO- -T 3 http://db:8080/hostname; echo -
Deny all ingress, then allow only
role=apion port 8080.Terminal window kubectl apply -f - <<'EOF'apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: default-deny-ingressspec:podSelector: {}policyTypes: ["Ingress"]---apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: db-from-apispec:podSelector:matchLabels:app: dbpolicyTypes: ["Ingress"]ingress:- from:- podSelector:matchLabels:role: apiports:- protocol: TCPport: 8080EOF -
Test both clients again.
Terminal window kubectl exec api -- wget -qO- -T 3 http://db:8080/hostname; echokubectl exec other -- wget -qO- -T 3 http://db:8080/hostname; echo
What you should see: After the policies, api gets a reply and other times out. kind’s default CNI (kindnet) enforces NetworkPolicy since kind v0.24; on a CNI that doesn’t, the same YAML is accepted and silently ignored, which is the trap to remember.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace cka-netpolPractise
- Write a default-deny ingress policy plus one rule that only allows pods labelled
role=frontend.
On this site
Use ClusterIP, NodePort, LoadBalancer service types and endpoints
Section titled “Use ClusterIP, NodePort, LoadBalancer service types and endpoints”Know
- ClusterIP is internal; NodePort opens a port on every node; LoadBalancer asks the cloud for an external load balancer. EndpointSlices hold the backing pod addresses.
Read
Demo: One app, three Service types
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-svctypeskubectl config set-context --current --namespace=cka-svctypes -
Expose one Deployment three ways.
Terminal window kubectl create deployment web --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 --replicas=2 -- /agnhost netexec --http-port=8080kubectl expose deployment web --name=web-cip --port=80 --target-port=8080kubectl expose deployment web --name=web-np --type=NodePort --port=80 --target-port=8080kubectl expose deployment web --name=web-lb --type=LoadBalancer --port=80 --target-port=8080kubectl get services -
Reach each one from where it is meant to be reached.
Terminal window kubectl run client --rm -i --restart=Never --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 -- wget -qO- -T 3 http://web-cip/hostname; echoNP=$(kubectl get service web-np -o jsonpath='{.spec.ports[0].nodePort}')docker exec kind-control-plane curl -s http://kind-worker:$NP/hostname; echokubectl get service web-lb -w # wait for an EXTERNAL-IP (cloud-provider-kind must be running), then Ctrl-CLB=$(kubectl get service web-lb -o jsonpath='{.status.loadBalancer.ingress[0].ip}')docker exec kind-control-plane curl -s http://$LB/hostname; echo -
Read the endpoints all three share.
Terminal window kubectl get endpointslices -l kubernetes.io/service-name=web-lb -o wide
What you should see: ClusterIP answers inside the cluster only, NodePort answers on a high port on every node, and LoadBalancer gets an external IP from cloud-provider-kind. Each type builds on the previous one: a LoadBalancer Service also has a node port and a cluster IP.
Note: The curl calls run inside a kind node because it sits on the same Docker network as the load balancer; that works on Linux, macOS, and Windows.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace cka-svctypesPractise
- Expose a Deployment as NodePort on a fixed port and reach it from the node.
On this site
Use the Gateway API to manage Ingress traffic
Section titled “Use the Gateway API to manage Ingress traffic”Know
- GatewayClass (implementation), Gateway (listeners, owned by the platform team), HTTPRoute (rules, owned by app teams). Status conditions report whether a route was accepted.
Read
Demo: Route two hostnames with a Gateway and HTTPRoutes
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-gatewaykubectl config set-context --current --namespace=cka-gateway -
cloud-provider-kind installs the Gateway API CRDs and a GatewayClass for you.
Terminal window kubectl get gatewayclasskubectl get crd | grep gateway.networking.k8s.io -
Two backends, one shared Gateway, one HTTPRoute per app team.
Terminal window for v in blue green; dokubectl create deployment $v --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- /agnhost netexec --http-port=8080kubectl expose deployment $v --port=80 --target-port=8080donekubectl apply -f - <<'EOF'apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata:name: webspec:gatewayClassName: cloud-provider-kindlisteners:- name: httpprotocol: HTTPport: 80---apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata:name: bluespec:parentRefs:- name: webhostnames: ["blue.example"]rules:- backendRefs:- name: blueport: 80---apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata:name: greenspec:parentRefs:- name: webhostnames: ["green.example"]rules:- matches:- path:type: PathPrefixvalue: /hostnamebackendRefs:- name: greenport: 80EOFkubectl wait --for=condition=Programmed gateway/web --timeout=120s -
Send requests to the Gateway address with each host name.
Terminal window GW=$(kubectl get gateway web -o jsonpath='{.status.addresses[0].value}')docker exec kind-control-plane curl -s -H 'Host: blue.example' http://$GW/hostname; echodocker exec kind-control-plane curl -s -H 'Host: green.example' http://$GW/hostname; echodocker exec kind-control-plane curl -s -o /dev/null -w '%{http_code}\n' -H 'Host: green.example' http://$GW/echokubectl get httproute green -o jsonpath='{.status.parents[0].conditions[*].type}{"\n"}'
What you should see: blue.example answers with a blue pod name and green.example with a green one. The green route only matches /hostname, so /echo on that host returns 404. The route status shows Accepted and ResolvedRefs. Gateway API splits roles: the platform team owns the Gateway, each app team owns its routes.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace cka-gatewayPractise
- Route
/apiand/to two different Services with one HTTPRoute.
On this site
Know how to use Ingress controllers and Ingress resources
Section titled “Know how to use Ingress controllers and Ingress resources”Know
- An Ingress needs a controller that matches its
ingressClassName. Path types: Exact, Prefix, ImplementationSpecific.
Read
Demo: An Ingress with host rules
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-ingresskubectl config set-context --current --namespace=cka-ingress -
An Ingress does nothing without a controller. Check which classes exist.
Terminal window kubectl get ingressclass -
Two backends, one Ingress, one rule per host.
Terminal window for v in foo bar; dokubectl create deployment $v --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- /agnhost netexec --http-port=8080kubectl expose deployment $v --port=80 --target-port=8080donekubectl create ingress demo --class=cloud-provider-kind \--rule="foo.example/*=foo:80" --rule="bar.example/*=bar:80"kubectl get ingress demo -o yaml | sed -n '/^spec:/,/^status:/p'kubectl get ingress demo -w # wait for an ADDRESS, then Ctrl-C -
Call each host, then one the rules don’t cover.
Terminal window IP=$(kubectl get ingress demo -o jsonpath='{.status.loadBalancer.ingress[0].ip}')docker exec kind-control-plane curl -s -H 'Host: foo.example' http://$IP/hostname; echodocker exec kind-control-plane curl -s -H 'Host: bar.example' http://$IP/hostname; echodocker exec kind-control-plane curl -s -o /dev/null -w '%{http_code}\n' -H 'Host: other.example' http://$IP/hostname
What you should see: The YAML shows what --rule generated: pathType: Prefix for /*. Each host reaches its own Deployment and the unknown host gets a 404. The lab uses cloud-provider-kind as the controller. Ingress NGINX, long the default choice, was retired in March 2026 and gets no more security fixes; for new work prefer the Gateway API.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace cka-ingressOn this site
Understand and use CoreDNS
Section titled “Understand and use CoreDNS”Know
- CoreDNS serves
<service>.<namespace>.svc.cluster.localand is configured by thecorednsConfigMap inkube-system.
Read
Demo: How names resolve, and how to change it
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace cka-dnskubectl config set-context --current --namespace=cka-dns -
Look at a pod’s resolver settings and resolve names at different scopes.
Terminal window kubectl create deployment web --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- /agnhost netexec --http-port=8080kubectl expose deployment web --port=80 --target-port=8080kubectl run dns --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 -- sleep 3600kubectl wait --for=condition=Ready pod/dns --timeout=120skubectl exec dns -- cat /etc/resolv.confkubectl exec dns -- nslookup webkubectl exec dns -- nslookup web.cka-dns.svc.cluster.localkubectl exec dns -- nslookup kubernetes.default -
Read the CoreDNS configuration, then add a static host entry.
Terminal window kubectl get configmap coredns -n kube-system -o jsonpath='{.data.Corefile}'kubectl get configmap coredns -n kube-system -o jsonpath='{.data.Corefile}' > Corefile.origkubectl get configmap coredns -n kube-system -o jsonpath='{.data.Corefile}' \| sed 's/ ready/ hosts {\n 10.0.0.42 legacy.internal\n fallthrough\n }\n ready/' > Corefilekubectl create configmap coredns -n kube-system --from-file=Corefile --dry-run=client -o yaml | kubectl apply -f -sleep 40; kubectl exec dns -- nslookup legacy.internal
What you should see: resolv.conf has search domains, which is why the short name web works inside the namespace. After the Corefile change (CoreDNS reloads it within about 30 seconds), legacy.internal resolves to 10.0.0.42.
Clean up:
cp Corefile.orig Corefile && kubectl create configmap coredns -n kube-system --from-file=Corefile --dry-run=client -o yaml | kubectl apply -f -rm -f Corefile Corefile.origkubectl config set-context --current --namespace=defaultkubectl delete namespace cka-dnsPractise
- Add a stub domain to the CoreDNS ConfigMap and test resolution from a pod.
On this site
Domain and competency names are from the CNCF CKA curriculum (v1.37), cncf/curriculum, licensed CC BY 4.0. Summaries, demos, and exercises are original to this site.