This challenge checks that you can, on your own, give an application its own identity, leave it only the right it needs, cut the token of a Pod that never calls the API and harden a Pod without breaking it. It is meant for people who have just followed the lesson ServiceAccounts for developers of the Workload security module. It runs in a dsoxlab virtual machine, on a kubeadm cluster with Kubernetes 1.37, and takes about 40 minutes. It gives no hints and teaches nothing new: it checks what the lessons of the module and their guided lab have already let you practice.
What you will learn
The lab enters the Pod of collecte, queries the API with its token, then reads the effective rights that the API computes for each identity. It checks that you can:
- Run an application under a dedicated ServiceAccount, not under the default account.
- Let it read the log of the Pods of another namespace with its own token.
- Leave it no other right, anywhere.
- Cut the token of a Pod that never calls the API.
- Remove from the default account of the namespace the rights it inherited.
- Harden the Pod of the application without stopping it from working.
What should you be able to do before you start?
No step-by-step guide goes with the challenge, and choosing the right objects is part of what it checks. Everything it asks is taught in three lessons:
- ServiceAccounts for developers, whose guided lab
cka-rbac-serviceaccountlets you practice the identity of an application, its Role and its RoleBinding. - Kubernetes RBAC: manage access securely, which teaches Roles, RoleBindings, the
pods/logsubresource and how to read the rights of an identity. - Kubernetes Security Context: control your Pods' permissions, which teaches how to harden a Pod.
If one of these points feels unclear, reread the lesson before you start.
What does the statement ask for?
The operations team installed two tools in the observatoire namespace of the kubeadm cluster. collecte must read the logs of the Pods of the production namespace, to extract incidents from them; the production Pod to watch is named commandes. tableau serves a static page and never calls the API. Both run today under the default account of observatoire. To "make it work", someone gave that account broad rights in the namespace, and collecte still does not read the logs of production. You are on the control plane, with kubectl configured.
The statement says what must be true at the end, never how to get there:
collecteruns under its own identity, namedcollecte, not under the default account.- From the Pod of
collecte, with its own token, reading the log of thecommandesPod ofproductionsucceeds. This requirement is blocking. - That is all: the
collecteidentity has no other right, anywhere. It cannot create, change or delete anything inproduction, read its Secrets, look at another namespace, logs included, or hold any right on the cluster. This requirement is blocking. - The running Pod of
tableaucarries no token: nothing is mounted in/var/run/secrets/kubernetes.io/serviceaccount. - The default account of
observatoirekeeps no right, in the namespace or elsewhere, beyond what Kubernetes gives every account: asking about its own rights. - The Pod of
collecteis hardened: it runs as non-root under a numeric UID, cannot escalate its privileges, has a read-only root filesystem and has dropped all its capabilities. Hardened, it still reads the log ofproduction.
How do you start the challenge and get graded?
The lab prepares the cluster and reads its state again when you ask for your grade. You start it with dsoxlab run k8s-challenge-identite-et-droits-minimaux. Two commands are then used: dsoxlab check k8s-challenge-identite-et-droits-minimaux tells you where you stand, criterion by criterion, as many times as you like, and dsoxlab submit k8s-challenge-identite-et-droits-minimaux returns the final result. The grade never looks at the commands you typed: the tests enter the Pod of collecte, query the API with its token, then have the API compute the effective rights of each identity. The application, not the administrator, must hold these rights.
Put it into practice
This lab is the challenge itself. It puts you in front of the situation described above and it is validated on the state of the cluster, as a colleague taking over your work would do.
How is the challenge graded?
The pass mark is 70 out of 100. The six requirements weigh the same. Requirements 2 and 3 are blocking: if one of the two is not met, the challenge fails, whatever the total. Passing the others does not make up for failing them.
The dsoxlab check output is limited to the list of unmet criteria, by their label, and the grade: no message says why. If a criterion resists, reread the lesson that teaches it, among those in the list at the start, then run dsoxlab check again.
Key points
- The challenge is a final exercise to do alone and without hints: it explains nothing and grades the state of the cluster, not your commands.
- Requirements 2 and 3 are blocking: reading the log of
production, and nothing more. - The rights are read from the identity of the application, with its own token: what the administrator can do does not count.
dsoxlab checkshows where you stand as often as you like;dsoxlab submitreturns the result.