Exam CKS Topic 2 Question 12 Discussion

Actual exam question for Linux Foundation's CKS exam
Question #: 12
Topic #: 2
You are managing a Kubernetes cluster With several applications running within pods. Your security policy mandates that all pods should run with the 'privileged' flag set to 'false' , while allowing a few pods to run with privileged access for specific tasks. How would you implement this policy by leveraging the Kubernetes security best practices?

Suggested Answer:

Solution (Step by Step) :
1. Create a Security Context Constraint (SCC): Create a new SCC named 'non-privileged-sce with the following configuration:
- 'allowPrivilegeEscalation': 'false' (Prevents pods from elevating privileges even if they run with privileged containers)
- 'privileged': 'false' (Disallows containers from running with privileged access)
- 'runAsLJser': ' 1000' (Assigns a specific non-root user ID for containers)
- 'readOnlyRootFilesystem': 'true' (Prevents containers from modifying the host's root filesystem)
- 'seccompProfile': 'localhost/unconfined' (Specifies a seccomp profile for restricting system calls)

2. Apply the SCC: Apply the SCC using 'kuoectl apply -f non-privileged-scc.yaml 3. Create a Second SCC for Privileged Pods: Create a new SCC named 'privileged-sce with the following configuratiom - 'allowPrivilegeEscalation': 'trues - 'privileged': 'true' - 'runAsuser': - 'readOnlyRootFilesystem': 'false' - 'seccompprofile': 'localhost/unconfined'

4. Apply the Privileged SCC: Apply the SCC using 'kubectl apply -f privileged-scc.yaml 5. Update Your Deployment Configurations: - For deployments requiring privileged access, include 'securityContext.securityContextConstraints: privileged-sce within the pod specification. - For all other deployments, include 'securityContext.securityContextConstraints: non-prjvileged-scc' within the pod specification.

6. Restrict Access to SCCs: You can funer enhance security by configuring which users or service accounts can use each SCC. This can be done by using Role-Based Access Control (RBAC) to grant permissions to specific user accounts or service accounts for the SCCs.

This approach ensures that the majority of pods operate with minimal privileges, enhancing security, while allowing a few essential deployments to run with elevated access. Remember to constantly review and update your security policies as your cluster and applications evolve.

by Levi at Apr 19, 2026, 04:16 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10