KCSA: Overview of Cloud Native Security
14% of the KCSA exam, 6 competencies. Back to the KCSA 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.
The 4Cs of Cloud Native Security
Section titled “The 4Cs of Cloud Native Security”Know
- Cloud, cluster, container, code: each layer can only be as secure as the one around it.
Read
Demo: One check per layer
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcsa-4cskubectl config set-context --current --namespace=kcsa-4cs -
Cloud and node: the host kernel every container shares.
Terminal window docker exec kind-worker uname -rkubectl run probe --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 -- sleep 3600 && kubectl wait --for=condition=Ready pod/probe --timeout=60skubectl exec probe -- uname -r -
Cluster: how the API server authenticates and authorizes.
Terminal window docker exec kind-control-plane grep -E -- '--(authorization-mode|anonymous-auth|enable-admission-plugins|client-ca-file)' /etc/kubernetes/manifests/kube-apiserver.yaml -
Container: what the process runs as by default.
Terminal window kubectl exec probe -- idkubectl exec probe -- grep CapEff /proc/1/status
What you should see: The pod reports the same kernel as the node: a kernel exploit in any container is a node compromise. The API server uses Node,RBAC authorization and client certificates. The container runs as root with a set of default capabilities. Code, the fourth C, is the part only you can fix.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace kcsa-4csCloud Provider and Infrastructure Security
Section titled “Cloud Provider and Infrastructure Security”Know
- Lock down node access, the cloud metadata API, the control plane endpoint, and network paths to etcd.
Read
Demo: What a node exposes, and blocking the metadata service
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcsa-infrakubectl config set-context --current --namespace=kcsa-infra -
List what listens on a node. Each port is attack surface.
Terminal window docker exec kind-worker ss -tlnp -
Block pods from reaching the cloud metadata address while allowing everything else.
Terminal window kubectl apply -f - <<'EOF'apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: no-metadataspec:podSelector: {}policyTypes: ["Egress"]egress:- to:- ipBlock:cidr: 0.0.0.0/0except:- 169.254.169.254/32EOFkubectl get networkpolicy no-metadata -o yaml | sed -n '/^spec:/,$p'
What you should see: The node listens on the kubelet API (10250), kube-proxy’s health and metrics ports, and containerd’s local endpoints. kind runs on your machine, so there is no metadata service to reach; on a cloud node the same policy stops a compromised pod from fetching the node’s cloud credentials from 169.254.169.254.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace kcsa-infraControls and Frameworks
Section titled “Controls and Frameworks”Know
- Preventive (RBAC, admission), detective (audit logs, runtime detection), and corrective controls, mapped to frameworks such as CIS Benchmarks and NIST.
Read
Demo: use the CKS demo for “Use CIS benchmark to review the security configuration of Kubernetes components (etcd, kubelet, kubedns, kubeapi)”. The CIS Kubernetes Benchmark is the framework you will meet most often; the CKS demo runs it against the lab cluster with kube-bench.
Isolation Techniques
Section titled “Isolation Techniques”Know
- Namespaces, RBAC, NetworkPolicies, node isolation with taints, sandboxed runtimes (gVisor, Kata) via RuntimeClass.
Read
Demo: What a pod sees with and without host namespaces
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcsa-isolationkubectl config set-context --current --namespace=kcsa-isolation -
A normal pod sees only its own processes.
Terminal window kubectl run normal --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 -- sleep 3600kubectl wait --for=condition=Ready pod/normal --timeout=60skubectl exec normal -- ps -
A pod with
hostPID: truesees every process on the node, including the kubelet.Terminal window kubectl run hostpid --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 --overrides='{"spec":{"hostPID":true}}' -- sleep 3600kubectl wait --for=condition=Ready pod/hostpid --timeout=60skubectl exec hostpid -- sh -c 'ps | grep -E "kubelet|containerd" | grep -v grep | head -3' -
Ask the namespace to refuse that.
Terminal window kubectl label namespace kcsa-isolation pod-security.kubernetes.io/enforce=baselinekubectl run hostpid2 --image=registry.k8s.io/e2e-test-images/busybox:1.37.0-2 --overrides='{"spec":{"hostPID":true}}' -- sleep 3600
What you should see: The normal pod lists two processes. The hostPID pod lists the kubelet and containerd. Under the baseline level that pod is rejected with host namespaces (hostPID=true). Linux namespaces are the isolation; host namespaces switch it off.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace kcsa-isolationArtifact Repository and Image Security
Section titled “Artifact Repository and Image Security”Know
- Use private registries, scan images, pin by digest, and sign images.
Read
Demo: Pin by digest and see what the node trusts
-
Create a namespace for this demo and make it the default for your context.
Terminal window kubectl create namespace kcsa-artifactskubectl config set-context --current --namespace=kcsa-artifacts -
Read the digest a tag resolved to, then run by digest.
Terminal window kubectl run bytag --image=registry.k8s.io/e2e-test-images/agnhost:2.66.1 -- pausekubectl wait --for=condition=Ready pod/bytag --timeout=120sREF=$(kubectl get pod bytag -o jsonpath='{.status.containerStatuses[0].imageID}'); echo $REFkubectl run bydigest --image="$REF" -- pause -
Inspect the image on the node through the runtime.
Terminal window NODE=$(kubectl get pod bytag -o jsonpath='{.spec.nodeName}')docker exec $NODE crictl inspecti registry.k8s.io/e2e-test-images/agnhost:2.66.1 | jq '.status.repoDigests, .status.size'
What you should see: A tag such as 2.66.1 can be re-pushed to point at different content; the sha256: digest can’t. Pinning by digest in manifests, together with signature verification (see the CKS supply chain demos), is how you make sure what runs is what you reviewed.
Clean up:
kubectl config set-context --current --namespace=defaultkubectl delete namespace kcsa-artifactsOn this site
Workload and Application Code Security
Section titled “Workload and Application Code Security”Know
- Run as non-root, drop capabilities, read-only root filesystem, and keep secrets out of images.
Read
Demo: use the CKAD demo for “Understand Application Security (SecurityContexts, Capabilities, etc.)”. It locks down a pod with a non-root user, a read-only root filesystem, and no capabilities, and tests each control from inside.
Domain and competency names are from the CNCF KCSA curriculum (current curriculum (unversioned)), cncf/curriculum, licensed CC BY 4.0. Summaries, demos, and exercises are original to this site.