KCNA: Container Orchestration
28% of the KCNA exam, 4 competencies. Back to the KCNA 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.
Networking
Section titled “Networking”Know
- Every pod gets its own IP, and pods can reach each other without NAT. A CNI plugin implements this.
- Services give a stable virtual IP and DNS name in front of a changing set of pods.
- Ingress and Gateway API route HTTP traffic from outside the cluster to Services.
Read
Demo: A Service in front of moving pods
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcna-netkubectl config set-context --current --namespace=kcna-net -
Run three replicas and put a Service in front.
Terminal window kubectl create deployment web --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 --replicas=3 -- /agnhost netexec --http-port=8080kubectl expose deployment web --port=80 --target-port=8080kubectl rollout status deployment/web -
Call it by DNS name a few times from another pod.
Terminal window kubectl run client --rm -i --restart=Never --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 -- \sh -c 'for i in 1 2 3 4 5 6; do wget -qO- -T 3 http://web/hostname; echo; done' -
See what the Service really points at.
Terminal window kubectl get pods -l app=web -o widekubectl get endpointslices -l kubernetes.io/service-name=web
What you should see: The replies rotate between pod names. The EndpointSlice lists the pod IPs behind the stable Service IP; delete a pod and the slice updates while the name web keeps working.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace kcna-netPractise
- Expose a Deployment as a Service and resolve its name from another pod.
On this site
Security
Section titled “Security”Know
- The 4Cs: cloud, cluster, container, code. Each layer depends on the one around it.
- RBAC grants permissions; Pod Security Standards restrict what pods may do; Secrets hold sensitive data but are only base64 unless encrypted at rest.
Read
Demo: Let the cluster refuse a risky pod
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcna-seckubectl config set-context --current --namespace=kcna-sec -
Turn on the
restrictedPod Security level for a namespace.Terminal window kubectl label namespace kcna-sec pod-security.kubernetes.io/enforce=restricted -
Try a pod that runs as root with default settings.
Terminal window kubectl run rooty --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- pause -
Now one that meets the standard.
Terminal window kubectl apply -f - <<'EOF'apiVersion: v1kind: Podmetadata:name: tidyspec:securityContext:runAsNonRoot: truerunAsUser: 65534seccompProfile:type: RuntimeDefaultcontainers:- name: appimage: registry.k8s.io/e2e-test-images/agnhost:2.66.1args: ["pause"]securityContext:allowPrivilegeEscalation: falsecapabilities:drop: ["ALL"]EOFkubectl get pod tidy
What you should see: The first pod is rejected with violates PodSecurity "restricted:latest" and a list of every setting it is missing. The second is admitted. Nothing changed in the image; the pod spec is what the policy judges.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace kcna-secOn this site
Troubleshooting
Section titled “Troubleshooting”Know
- Start from status and events:
kubectl get,kubectl describe, then logs withkubectl logs --previous. - Know the common pod states: Pending, ContainerCreating, CrashLoopBackOff, ImagePullBackOff, OOMKilled.
Read
Demo: Three broken pods, three different signals
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcna-troublekubectl config set-context --current --namespace=kcna-trouble -
Break a pod three ways.
Terminal window kubectl run badimage --image=registry.k8s.io/e2e-test-images/does-not-exist:1.0kubectl run badcmd --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 -- sh -c 'echo starting; exit 1'kubectl apply -f - <<'EOF'apiVersion: v1kind: Podmetadata:name: hungryspec:containers:- name: appimage: registry.k8s.io/e2e-test-images/busybox:1.37.0-2command: ["sh", "-c", "tail /dev/zero"]resources:limits:memory: 64MiEOF -
Read the status column, then describe each one.
Terminal window sleep 30; kubectl get podskubectl describe pod badimage | sed -n '/Events:/,$p'kubectl logs badcmd --previouskubectl get pod hungry -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}{"\n"}'
What you should see: badimage goes ErrImagePull then ImagePullBackOff, badcmd goes CrashLoopBackOff and its previous log says “starting”, and hungry is killed with reason OOMKilled. Each status points you to a different place to look.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace kcna-troublePractise
- Break a pod three ways (bad image, bad command, too little memory) and identify each from
kubectl describealone.
On this site
Storage
Section titled “Storage”Know
- Volumes live as long as the pod; PersistentVolumes outlive it. A PersistentVolumeClaim requests storage, a StorageClass provisions it dynamically.
- CSI drivers connect Kubernetes to storage systems.
Read
Demo: Data that outlives the pod
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcna-storagekubectl config set-context --current --namespace=kcna-storage -
Claim storage from the default StorageClass.
Terminal window kubectl get storageclasskubectl apply -f - <<'EOF'apiVersion: v1kind: PersistentVolumeClaimmetadata:name: dataspec:accessModes: ["ReadWriteOnce"]resources:requests:storage: 1GiEOFkubectl get pvc data -
Write a file from one pod, delete the pod, read it from another.
Terminal window cat > writer.yaml <<'EOF'apiVersion: v1kind: Podmetadata:name: writerspec:containers:- name: appimage: registry.k8s.io/e2e-test-images/busybox:1.37.0-2command: ["sh", "-c", "date >> /data/log; cat /data/log; sleep 3600"]volumeMounts:- name: datamountPath: /datavolumes:- name: datapersistentVolumeClaim:claimName: dataEOFkubectl apply -f writer.yaml && kubectl wait --for=condition=Ready pod/writer --timeout=120skubectl delete pod writerkubectl apply -f writer.yaml && kubectl wait --for=condition=Ready pod/writer --timeout=120skubectl logs writer
What you should see: The claim stays Pending until the first pod uses it: kind’s standard class uses WaitForFirstConsumer. The second pod prints two dates, so the file survived the first pod being deleted.
Clean up:
rm -f writer.yamlkubectl config set-context --current --namespace=defaultkubectl delete namespace kcna-storageOn this site
Domain and competency names are from the CNCF KCNA curriculum (current curriculum (unversioned)), cncf/curriculum, licensed CC BY 4.0. Summaries, demos, and exercises are original to this site.