The CI service account that became cluster-admin
Read cluster role bindings, ask the API what a CI service account can do with kubectl auth can-i, and find the “temporary” binding that gave it every permission.
What you’re looking at
Read cluster role bindings, ask the API what a CI service account can do with kubectl auth can-i, and find the “temporary” binding that gave it every permission.
Your goal: Find the temporary binding that made a CI service account all-powerful, and what it really needs.
- Briefing
- the story: what happened and what evidence you were handed.
- Terminal
- the dark box. It is a pretend Linux shell that runs in your browser. Type a command and press Enter. Nothing you type touches a real system.
- Walkthrough
- the numbered path. Each step says what to type and what you should see. Hints open one at a time.
- Answer boxes
- under each question step. Type what you found and press Check.
Words you will meet
- CI
- continuous integration, the server that builds and tests code
- API
- application programming interface, how programs talk to a service
Start with step 1 in the walkthrough. Every step says what to do and what you should see. The whole thing takes about 2 min to talk through.
Briefing
The CI pipeline deploys with the service account ci/deployer. It should only patch deployments. Six days ago a release failed with a permissions error and someone “fixed” it.
kubectl get clusterrolebindings -o wide lists each binding with its subjects. kubectl auth can-i --as=system:serviceaccount:<ns>:<name> asks the authorizer directly, which counts every binding at once.
ops-bastion · Kubernetes review
Type help for the command list and objectives for your tasks. Everything runs in this browser.
Up and down arrows walk your history. Ctrl+L clears the screen. Try help, ls, and objectives.
The whole walkthrough
Every step in order, written to be read aloud: 259 words, about 2 min. It gives away every answer, so try the steps first.