CKS Practice Tasks: 20 Timed Security Scenarios to Drill
Twenty original CKS practice tasks grouped by the six security domains, each with a time budget, verification command and common trap. These are original practice scenarios, not exam questions.
1. How to use these cks practice tasks under time pressure
These cks practice tasks are twenty original timed scenarios written for this article, not actual CKS exam questions, and they mirror the six official security domains. Run each task against a disposable cluster with a visible timer, verify the result with the command given, then note the trap you nearly fell into.
The opening incident is an illustrative composite, not a named outage. A platform team passed its internal security review on paper, then watched a routine audit find a default service account bound to a broad role, a namespace with no default-deny policy, and images pulled from an unapproved registry. Nothing had failed yet. The gap was that nobody had practised fixing those controls under time pressure, so each fix became a research project during the audit window.
That is the skill these cks practice tasks build. The CKS format rewards engineers who can secure a live cluster at a command line, so practice should feel like operations, not revision. Work in a throwaway cluster you can reset. Set the timer before you read the task twice. Use documentation-style habits: check current state first, make the smallest change that satisfies the requirement, then verify behaviour rather than trusting that a manifest applied cleanly.
Keep a score sheet with three columns: finished inside the budget, verified, and trap avoided. A task only counts when all three are true. If you run over, do not extend the timer quietly. Mark it, finish the verification, and move on. Reviewing where minutes leaked teaches more than one perfect slow run.
Pair this set with the general drills in Kubernetes interview troubleshooting drills when you want mixed fault-finding, and keep the security set for domain depth. Two full passes, spaced a week apart, beat five rushed passes in one weekend.
One more habit separates strong runs from lucky ones: narrate your verification before you run it. Say what success looks like, what failure would look like, and which command distinguishes them. That thirty-second habit prevents the most common practice error, which is running a command, seeing output, and declaring victory without checking whether the output actually proves the control works. In production the same habit turns a vague claim that a policy exists into evidence an auditor can re-run. It also exposes weak controls early, while the cluster is still disposable and the cost of fixing them is a few minutes rather than an incident review. Keep the narration short, keep it honest, and let the command output have the final word every single time.
2. cks practice tasks for cluster setup and NetworkPolicy
Cluster setup cks practice tasks test whether you can restrict network access, secure ingress, and check control-plane configuration quickly. Start by confirming the CNI actually enforces policy, apply a default-deny baseline, then allow only the flows the workload needs and prove both the allowed and blocked paths work.
Task 1 — Default-deny a namespace, then allow one flow (8 minutes). In namespace shop, create a NetworkPolicy that denies all ingress and egress, then add a second policy allowing pods labelled app=web to reach app=api on port 8080 and DNS on port 53. Confirm enforcement exists before you trust the result. Verification: kubectl -n shop get networkpolicy; kubectl -n shop exec deploy/web -- wget -qO- http://api:8080/health. Common trap: forgetting DNS egress, so every lookup fails and the allow rule looks broken when it is not.
Task 2 — Terminate TLS at ingress with a real certificate (7 minutes). Create an Ingress for app.example.com that redirects HTTP to HTTPS, references a TLS secret, and only accepts the /api path. Use a self-signed certificate for practice and confirm the redirect header rather than assuming the annotation worked. Verification: kubectl get ingress -n shop; curl -skI https://app.example.com/api | head -n 5. Common trap: putting the TLS secret in a different namespace from the Ingress, which silently leaves the default certificate in place.
Task 3 — Run a CIS-style check on kubelet settings (6 minutes). Inspect the kubelet configuration on a node, identify whether anonymous authentication is disabled and the read-only port is closed, and record the exact settings you found. Fix one finding and restart the kubelet cleanly. Verification: grep -E 'anonymous|readOnlyPort' /var/lib/kubelet/config.yaml; systemctl status kubelet. Common trap: editing the config file but never restarting the kubelet, so the running process keeps the old settings.
Network work fails quietly. A policy can apply without error and still do nothing if the CNI does not enforce it, and a TLS annotation can be ignored when the secret is missing. That is why every cluster setup task here ends with a behaviour check: a request that should succeed and one that should fail. Read Kubernetes NetworkPolicy troubleshooting before this block if policy selectors still feel fuzzy, then run the tasks without notes.
3. cks practice tasks for cluster hardening and RBAC
Cluster hardening cks practice tasks focus on RBAC least privilege, cautious service-account use, and restricting API access. The habit to build is checking effective permissions with kubectl auth can-i before and after every change, because a role that looks narrow in YAML can still grant far more than intended.
Task 4 — Scope a role to one namespace and two verbs (6 minutes). Create a Role in namespace shop allowing get and list on pods only, bind it to user auditor, and prove the user cannot delete pods or read secrets. Delete any broader binding you find for that user. Verification: kubectl auth can-i list pods -n shop --as=auditor; kubectl auth can-i delete pods -n shop --as=auditor. Common trap: using a ClusterRole out of habit, which grants the verbs in every namespace instead of one.
Task 5 — Stop pods using the default service account token (6 minutes). Create a dedicated service account api-runner, set automountServiceAccountToken: false on the default account, and redeploy the API pod so it uses the new account with no token mounted unless it calls the API. Verification: kubectl -n shop get pod -l app=api -o jsonpath='{.items[0].spec.serviceAccountName}'. Common trap: changing the service account but leaving old pods running, so the check passes on paper while live pods keep the old token.
Task 6 — Find and remove an over-broad cluster binding (7 minutes). List ClusterRoleBindings, find the one granting cluster-admin to a workload service account, replace it with a namespaced Role, and confirm the workload still performs its one legitimate API call. Verification: kubectl get clusterrolebindings -o wide; kubectl auth can-i get configmaps -n shop --as=system:serviceaccount:shop:api-runner. Common trap: deleting the binding before creating the replacement, which breaks the workload and tempts you to restore the broad grant.
RBAC mistakes are usually scope mistakes. Verbs get copied from examples, cluster scope feels convenient, and wildcard resources hide in long YAML files. Slow down on scope, then speed up on verification. The deeper reference is Kubernetes RBAC roles, bindings and least privilege; use it after the timed run to review any binding you hesitated over.
4. cks practice tasks for system hardening on nodes
System hardening cks practice tasks cover the host underneath Kubernetes: reducing the attack surface, limiting network exposure, and applying kernel controls such as seccomp and AppArmor. These tasks reward engineers who check what is actually running on the node instead of trusting the image or the manifest alone.
Task 7 — Apply a seccomp profile to a workload (6 minutes). Run a pod with the RuntimeDefault seccomp profile, then switch one container to a custom localhost profile that blocks a syscall the app never needs. Confirm the pod starts and the profile name is recorded on the running pod. Verification: kubectl -n shop get pod -l app=api -o jsonpath='{.items[0].spec.securityContext.seccompProfile.type}'. Common trap: setting the profile on the pod spec but referencing a localhost file that was never placed on the node.
Task 8 — Shrink node exposure and check listening ports (6 minutes). List listening ports on a node, identify one service that does not need external access, bind it to localhost or firewall it, and confirm the cluster still functions. Record before and after output in your notes. Verification: ss -tlnp; kubectl get nodes. Common trap: closing a port the kubelet or CNI needs, then debugging a node failure you created yourself.
Host tasks feel slow because they involve files, services, and restarts rather than one kubectl command. Practise the sequence until it is boring: inspect, change one thing, restart cleanly, verify the node reports Ready. A node that stays NotReady after hardening is not a security win; it is an outage with better intentions.
5. cks practice tasks for Pod Security Standards
Pod Security cks practice tasks test whether you can enforce restricted workloads without breaking legitimate applications. Apply the restricted standard at namespace level, fix the workload fields it rejects, and verify with a deliberately non-compliant pod that enforcement is real rather than a label nobody checks.
Task 9 — Enforce restricted Pod Security on a namespace (7 minutes). Label namespace shop to enforce the restricted Pod Security Standard, deploy a compliant nginx pod running as non-root with all capabilities dropped, and confirm a privileged pod is rejected with a clear admission error. Verification: kubectl label ns shop pod-security.kubernetes.io/enforce=restricted; kubectl -n shop get events --sort-by=.lastTimestamp. Common trap: labelling for warn or audit only, which reports violations but still lets privileged pods run.
Task 10 — Fix a workload that runs as root (6 minutes). Take a deployment whose container runs as root with a writable root filesystem, set runAsNonRoot, a fixed non-root user, readOnlyRootFilesystem: true, and drop all capabilities, adding back only what the process proves it needs. Verification: kubectl -n shop get deploy api -o yaml | grep -A6 securityContext. Common trap: setting runAsUser but leaving runAsNonRoot unset, so a future image change can silently return to root.
Task 11 — Isolate a tenant namespace with quotas and policies (7 minutes). Create namespace tenant-b with a ResourceQuota, a LimitRange, restricted Pod Security labels, and a default-deny NetworkPolicy. Deploy a small pod inside the quota and confirm an oversized request is rejected. Verification: kubectl -n tenant-b get resourcequota,limitrange,networkpolicy. Common trap: setting quotas so low that system pods fail, then loosening everything instead of sizing the quota properly.
The pattern in all three tasks is the same: enforcement first, then fix the workload, then try to break your own control. If the bad pod still runs, the control is decorative. Background reading: Kubernetes securityContext and Pod Security Standards.
6. cks practice tasks for secrets and encryption
Secrets cks practice tasks check whether sensitive data is encrypted at rest, mounted narrowly, and rotated without downtime. Treat every secret as compromised once it appears in a log, a shell history, or a broad RBAC grant, and practise the rotation path before you need it during an incident.
Task 12 — Encrypt secrets at rest and prove it (8 minutes). Configure an EncryptionConfiguration for secrets using a local key provider for practice, restart the API server components as your cluster requires, create a new secret, and confirm the stored value in etcd is not readable plaintext. Verification: kubectl -n shop create secret generic demo --from-literal=token=example; kubectl -n shop get secret demo -o jsonpath='{.data.token}' | base64 -d. Common trap: enabling encryption but never rewriting existing secrets, so old values stay in plaintext in etcd.
Task 13 — Rotate a secret without restarting everything (6 minutes). Create a new version of the API token secret, update the deployment to consume it through a mounted volume, roll the pods, and confirm the application reports the new token version while the old secret is deleted. Verification: kubectl -n shop rollout status deploy/api; kubectl -n shop get secret. Common trap: rotating the secret object but leaving pods on the old value because the value was injected as an environment variable at start time.
Mounted secret volumes refresh; environment variables do not. That single distinction decides whether rotation is a rollout or a restart-everything event. Also check who can read the secret: encryption at rest does not help when a broad RoleBinding lets every workload in the namespace list secrets.
7. cks practice tasks for supply chain security
Supply chain cks practice tasks cover image footprint, scanning, signing, and registry control. The goal is a chain you can describe end to end: a minimal base image, a scan gate that fails on critical findings, a signature you verify, and admission rules that only allow images from approved registries.
Task 14 — Scan an image and fail on critical findings (6 minutes). Scan a deliberately outdated image with your scanner of choice, identify the critical findings, rebuild on a current minimal base, and rescan until the gate passes. Record the before and after counts. Verification: trivy image --severity CRITICAL example/api:old; trivy image --severity CRITICAL example/api:new. Common trap: scanning the tag instead of the digest, so a retagged image slips past the gate you thought you set.
Task 15 — Verify an image signature before deployment (7 minutes). Sign a practice image with your signing tool, configure verification for the namespace, deploy the signed image successfully, then attempt the same image unsigned and confirm admission rejects it. Verification: cosign verify example/api:new; kubectl -n shop get events --sort-by=.lastTimestamp. Common trap: verifying signatures in CI but not at admission, so anyone with cluster access can bypass the pipeline.
Task 16 — Restrict pulls to approved registries (6 minutes). Write an admission rule or policy that only allows images from registry.example.com, deploy a compliant pod, then confirm a public-registry image is rejected with a readable message. Verification: kubectl -n shop run test --image=nginx --restart=Never; kubectl -n shop get events. Common trap: allowing the approved registry by prefix string match that an attacker-controlled hostname can also satisfy.
Supply chain controls fail at the seams: CI scans one thing, admission checks another, and the node pulls a third. Keep the digest as the unit of trust from build to admission. If your team debates policy engines, compare options in Kyverno vs Gatekeeper vs ValidatingAdmissionPolicy after the timed block.
8. cks practice tasks for admission control
Admission cks practice tasks test whether policy rejects bad workloads with messages an engineer can act on. A good policy names the field, the required value, and the fix, because a rejection nobody understands becomes a ticket asking for the policy to be disabled instead of the workload corrected.
Task 17 — Reject pods without resource limits (6 minutes). Create a policy requiring CPU and memory limits on every container, deploy a pod missing limits and confirm rejection, then add limits and confirm the same pod is admitted. Keep the error message specific. Verification: kubectl -n shop apply -f pod-no-limits.yaml; kubectl -n shop apply -f pod-with-limits.yaml. Common trap: writing the policy against the wrong resource shape, so init containers or sidecars bypass the check entirely.
Test admission policies with both the failing and passing case every time. Engineers trust a gate they have seen open for compliant work and close for non-compliant work. A gate tested only on the happy path tends to fail open in production, which is worse than no gate because everyone assumes protection exists.
9. cks practice tasks for runtime security
Runtime security cks practice tasks focus on detecting suspicious behaviour in running containers and keeping containers immutable. Practise reading detection output calmly: identify the process, the container, and the parent process, then decide whether you are looking at an attack, a misconfiguration, or your own test.
Task 18 — Detect a shell spawned in a container (7 minutes). With your runtime sensor running, exec into a practice pod and run a harmless suspicious command such as reading a sensitive file path. Find the alert, identify the container and process tree, and write down the evidence you would attach to an incident ticket. Verification: kubectl -n shop exec deploy/api -- cat /etc/shadow; kubectl -n shop logs -l app=runtime-sensor --tail=50. Common trap: treating every alert as an attack and deleting the pod before capturing the process evidence an investigator needs.
Task 19 — Make a container immutable at runtime (6 minutes). Set the root filesystem read-only, mount a small writable volume only where the app writes, disable privilege escalation, and confirm the app still serves traffic while writes outside the volume fail. Verification: kubectl -n shop exec deploy/api -- touch /test-write; kubectl -n shop get pod -l app=api -o jsonpath='{.items[0].spec.containers[0].securityContext.readOnlyRootFilesystem}'. Common trap: marking the filesystem read-only but forgetting the temp directory the app needs, then reverting the whole control under pressure.
Runtime tools differ in how they observe the kernel and how much noise they produce. Compare approaches in Kubernetes runtime security: Falco vs Tetragon and pick based on the signals your team will actually triage, not the longest feature list.
10. cks practice tasks for audit logging and investigation
Audit logging cks practice tasks test whether you can prove who did what in the cluster. Configure an audit policy that records secret access and RBAC changes, generate those events deliberately, then find them in the log with timestamps and usernames you could hand to an investigator without further cleanup.
Task 20 — Capture and query audit events for secret access (8 minutes). Enable an audit policy logging secret reads at metadata level or higher, read a secret as a test user, then query the audit log for that user, verb, and resource. Confirm RBAC changes are also recorded. Verification: kubectl -n shop get secret demo --as=auditor; grep '"verb":"get"' /var/log/kubernetes/audit.log | tail -n 5. Common trap: logging so much at full request-response level that the log volume becomes unusable and gets switched off.
Audit logs answer questions after the fact, which makes them easy to neglect during setup and impossible to reconstruct later. Practise the query, not just the configuration. If you cannot find your own test event in two minutes, an investigator will not find a real one either.
11. cks practice tasks time allocation by domain
Time allocation for cks practice tasks should follow domain weight and your personal miss rate, not equal slices. The three domains weighted at twenty percent deserve the most repetitions, while smaller domains need short, frequent drills so their procedures stay automatic when a task appears under exam pressure.
Use this table to plan a two-hour practice block. It mirrors the published domain weights and leaves buffer time, because finishing with verification time spare is a skill in itself.
| Domain | Weight | Practice minutes | Tasks here |
|---|---|---|---|
| Cluster Setup | 15% | 18 | 1-3 |
| Cluster Hardening | 15% | 18 | 4-6 |
| System Hardening | 10% | 12 | 7-8 |
| Minimize Microservice Vulnerabilities | 20% | 24 | 9-13 |
| Supply Chain Security | 20% | 24 | 14-17 |
| Monitoring, Logging and Runtime Security | 20% | 24 | 18-20 |
The minutes sum to 120 with no slack, which is deliberate for a second pass. On a first pass, allow twenty percent over and record where the overrun happened. Overruns cluster around restarts, certificate handling, and policy debugging, so those procedures deserve isolated repetitions until they stop costing minutes.
Decision rule: if a domain produced two misses, it gets the next practice block regardless of weight. Weight tells you where points live; your miss rate tells you where your points leak. Both numbers matter, and the second one is yours alone.
Review your score sheet weekly rather than after every session. Daily review overweights the most recent frustration, while a weekly view shows which traps repeat across domains. A repeated trap is a procedure gap, and procedure gaps close fastest with isolated repetitions: five short drills on the same control beat one long session that touches everything once. Track three numbers per domain: tasks finished inside budget, verifications passed first time, and traps avoided. When all three trend upward together, the domain is genuinely improving. When speed rises but verification failures rise with it, you are trading accuracy for pace, which is exactly the trade that timed security work punishes most.
12. cks practice tasks troubleshooting matrix and final checklist
A troubleshooting matrix for cks practice tasks turns repeated failures into fast pattern recognition. When a task stalls, match the symptom to the likely cause, run the listed check, and only then change configuration, because changing settings before confirming the cause usually adds a second problem to the first one.
| Symptom | Likely cause | First check |
|---|---|---|
| Policy applied, traffic still flows | CNI not enforcing NetworkPolicy | Test with a deny-all policy and a blocked request |
| Pod rejected after labelling namespace | Restricted standard missing fields | Read the admission error field by field |
| RBAC change has no effect | Wrong scope or stale binding | kubectl auth can-i with the exact user |
| TLS ingress serves default certificate | Secret in wrong namespace | Compare secret and ingress namespaces |
| Scan passes, admission rejects | Digest mismatch between stages | Compare the scanned and deployed digests |
| Audit event missing | Policy level too low for the verb | Generate a test event and query immediately |
Final checklist before you call a practice run complete:
- Every task verified with its command, not assumed from a clean apply.
- At least one negative test per control: the bad pod, the blocked request, the rejected image.
- Timer results recorded honestly, including overruns.
- Traps noted in your own words while the memory is fresh.
- Cluster reset or snapshot restored so the next run starts clean.
- One domain chosen for the next block based on misses, not comfort.
Repeat the full set until verification feels automatic. Security work in production follows the same rhythm as these cks practice tasks: inspect, change narrowly, verify behaviour, and write down what you proved. Engineers who internalise that loop stop fearing audits, because the controls they claim are controls they have personally tested.
Frequently Asked Questions
Are these cks practice tasks actual exam questions?
No. All twenty scenarios are original practice tasks written for this article. They are mapped to the public CKS domain structure so you can drill the same skills, but they do not reproduce exam content, wording, or environments.
How should I time these cks practice tasks?
Use the per-task budget with a visible timer and count a task complete only when its verification command passes. On a first pass allow twenty percent over, record the overrun, and tighten on the second pass a week later.
What cluster do I need for cks practice tasks?
Any disposable Kubernetes cluster where you can change RBAC, NetworkPolicy, and Pod Security labels safely. A local multi-node setup works; avoid practising hardening tasks on a shared or production cluster.
Which cks practice tasks matter most?
The three domains weighted at twenty percent each: minimizing microservice vulnerabilities, supply chain security, and monitoring, logging and runtime security. Tasks 9 to 20 cover those areas and deserve the most repetitions.
Do I need CKA before using cks practice tasks?
The CKS requires a passed CKA first, and these tasks assume you already create pods, roles, and policies fluently. If basic kubectl work is slow, drill administration tasks first, then return to this security set.
How do cks practice tasks help in production work?
Each scenario mirrors a real control: default-deny networking, least-privilege RBAC, restricted pods, signed images, and audit queries. Practising the verification step builds the habit of proving controls work instead of assuming manifests applied correctly.
What should I do when a cks practice task fails?
Match the symptom in the troubleshooting matrix, run the first check listed, and fix the confirmed cause only. Record the trap you hit; repeated traps, not single failures, decide which domain gets your next practice block.