BM: Baca dalam Bahasa Melayu
World K6: Guards
RBAC: roles and bindings
You will learn: how to give a person or a bot a job card for one zone, and nothing more.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
Your CI bot only updates one thing: the shop Deployment. Today it holds a master key to the whole cluster. Which key should it carry?
Pick one answer.
Exactly what it needs, nothing more. That is least privilege: Give each worker only the keys their station needs. Nothing extra..
Watch
Kubernetes knows two kinds of “who”. People bring their own ID. Robots get a staff badge: a ServiceAccount: A staff badge for a robot: the identity a pod or a CI bot uses with the API.. Sort them.
Drag a card into a box. Or tap the card, then tap the box.
Watch
kind-dev namespace defaultA Role: A job card: which verbs on which things, in one zone. A ClusterRole works in every zone. is a job card. It lists verbs, like patch, on things, like deployments. It works in one zone only.
Try it
A card does nothing alone. A RoleBinding: Pins a job card to a person or bot, in one zone. A ClusterRoleBinding pins it everywhere. pins it to a badge, in one zone. Wire the CI bot to deployer, in shop only.
Connect wires until every answer matches. Give only what is needed.
Who (plugs)
- ci-bot (ServiceAccount · ci)
- mei (user)
Roles (sockets)
- Role deployer · shop
get, list, patch · deployments
- ClusterRole cluster-admin · whole cluster
* · *
Wires (bindings)
No wires yet. Nobody can do anything.
Can they? (kubectl auth can-i)
kubectl auth can-i patch deployments -n shop --as=system:serviceaccount:ci:ci-botnoshould be yes not yetNo wire gives this right.kubectl auth can-i patch deployments -n default --as=system:serviceaccount:ci:ci-botnoshould be no matchesNo wire gives this right.kubectl auth can-i get secrets -n shop --as=system:serviceaccount:ci:ci-botnoshould be no matchesNo wire gives this right.
Ask your own question
kubectl auth can-i get pods -n shop --as=system:serviceaccount:ci:ci-botno
Hint
Who: ci-bot. Role: deployer. Where: shop.Watch
A Role works in one zone. A ClusterRole works in every zone, and for things with no zone, like nodes. Sort these.
Drag a card into a box. Or tap the card, then tap the box.
Try it
Now in the terminal. Apply the job card. Then pin it to ci-bot with a RoleBinding.
kind-dev namespace defaultHint
--serviceaccount takes zone:name, like default:ci-bot.Predict
RBAC has no “deny” rule. The bot has two RoleBindings. One allows deleting pods. One does not. Can it delete pods?
Pick one answer.
You did it!
You can now give a bot a job card for one zone.
Go deeper (optional)
A RoleBinding may point at a ClusterRole. Then that card works only in the binding’s zone. Built-in ClusterRoles: view, edit, admin, cluster-admin. Pods get a short-lived ServiceAccount token. Set automountServiceAccountToken: false when the app never calls the API.
Real mission
kubectl create serviceaccount ci-botkubectl create role deployer --verb=get,list,patch --resource=deploymentskubectl create rolebinding ci-bot-deployer --role=deployer --serviceaccount=default:ci-botkubectl describe rolebinding ci-bot-deployer
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Bot CI anda cuma kemas kini satu benda: Deployment shop. Hari ini ia pegang kunci induk seluruh kluster. Kunci apa patut ia bawa?
Tepat apa yang perlu, tidak lebih. Itulah least privilege (hak paling sedikit).
Kubernetes kenal dua jenis “siapa”. Orang bawa ID sendiri. Robot dapat lencana staf: ServiceAccount. Asingkan mereka.
Role ialah kad tugas. Ia senaraikan kata kerja, seperti patch, pada benda, seperti deployments. Ia hanya berfungsi dalam satu zon.
Kad sahaja tak buat apa-apa. RoleBinding pin kad pada lencana, dalam satu zon. Sambungkan bot CI pada deployer, dalam shop sahaja.
Role berfungsi dalam satu zon. ClusterRole berfungsi di semua zon, dan untuk benda tanpa zon, seperti node. Asingkan ini.
Sekarang di terminal. Apply kad tugas. Kemudian pin pada ci-bot dengan RoleBinding.
--serviceaccount ambil zon:nama, contohnya default:ci-bot.RBAC tiada peraturan “tolak”. Bot ada dua RoleBinding. Satu benarkan padam pod. Satu lagi tidak. Bolehkah ia padam pod?
Kini anda boleh beri bot satu kad tugas untuk satu zon.
You finished this before. Practice is always welcome!
Official docs: Using RBAC authorization · Service accounts · RBAC good practices
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?