BM: Baca dalam Bahasa Melayu
World K6: Guards
securityContext: lock the lunchbox
You will learn: the four locks the restricted level wants, and where each one goes.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
A thief breaks into one lunchbox: your shop’s container. It runs as root, with every power on. How far can the thief get?
Pick one answer.
Watch
Lock 1 goes on the whole tray. securityContext: The locks on a lunchbox: no root, no extra powers, a seccomp filter, read-only files. holds the locks. Tap the two lines that stop root.
Tap every line that keeps the cook from being root.
0 of 2 found
Hint
Root is user 0. Look for user words.Watch
kind-dev namespace defaultThe tray locks are not enough. Each container needs two more. capabilities: Small slices of root's power, like changing the network. Drop them ALL unless you need one. are slices of root’s power. Drop them all:
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]Try it
Mei put a container lock on the tray. The API server does not know it there. Move it into the container.
Fix the manifest, then press Apply.
Try it
Two trays wait in your folder. cat them, then apply the one the guard accepts.
kind-dev namespace defaultdev-control-planeOpenManagerNo trays here.
dev-workerOpenNo trays here.
dev-worker2OpenNo trays here.
Hint
Count the locks. The guard wants four.Predict
You add readOnlyRootFilesystem: true. The app writes a temp file to /tmp. What happens?
Pick one answer.
Check
Where can each lock go? Sort them.
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now lock a lunchbox with securityContext.
Go deeper (optional)
Restricted lets one power back in: NET_BIND_SERVICE, for ports under 1024. Many images run as root by default. With runAsNonRoot: true and a root image, the kubelet refuses to start it: CreateContainerConfigError. Pick a non-root image, or set runAsUser.
Real mission
kubectl create namespace locks && kubectl label ns locks pod-security.kubernetes.io/enforce=restrictedkubectl apply -n locks -f locked.yamlkubectl exec -n locks locked -- id
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Seorang pencuri pecah masuk satu bekas: container kedai anda. Ia berjalan sebagai root, dengan semua kuasa hidup. Sejauh mana pencuri boleh pergi?
Kunci 1 dipasang pada seluruh dulang. securityContext simpan kunci-kunci itu. Tekan dua baris yang halang root.
Kunci dulang belum cukup. Setiap container perlu dua lagi. Capabilities ialah cebisan kuasa root. Buang semuanya:
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
Mei letak kunci container pada dulang. API server tak kenal kunci itu di situ. Pindahkan ke dalam container.
Dua dulang menunggu dalam folder anda. cat kedua-duanya, kemudian apply yang pengawal terima.
Anda tambah readOnlyRootFilesystem: true. Aplikasi tulis fail sementara ke /tmp. Apa jadi?
Di mana setiap kunci boleh diletak? Asingkan.
Kini anda boleh kunci bekas dengan securityContext.
You finished this before. Practice is always welcome!
Official docs: Configure a security context · Pod Security Standards: restricted · Restrict a container's syscalls with seccomp
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?