Courseiva
System Hardening →hardMultiple Choice

CKS System Hardening Practice Question

A cluster administrator wants to enforce the Pod Security Standard 'restricted' at the namespace level. Which command applies the PodSecurity admission label to the 'prod' namespace?

⚠ Common exam trap

Watch out — candidates often confuse the three modes (enforce, audit, warn) and often pick `warn` or `audit` thinking they provide enforcement, or they mistakenly use an annotation instead of a label, which is not recognized by the PodSecurity admission controller.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

kubectl label namespace prod pod-security.kubernetes.io/enforce=restricted

The `enforce` label is the only one that actively blocks pods that violate the specified Pod Security Standard (PSS) level. The command `kubectl label namespace prod pod-security.kubernetes.io/enforce=restricted` applies the 'restricted' policy at the namespace level, causing the PodSecurity admission controller to reject any pod that does not comply with the restricted profile.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    kubectl label namespace prod pod-security.kubernetes.io/warn=restricted

    Why it's wrong here

    This command applies the `pod-security.kubernetes.io/warn` label, which instructs the Pod Security Admission controller to emit a warning message when a Pod violates the `restricted` policy, but it does not block the Pod's creation. Since admission is still allowed, this does not meet the administrator's requirement to enforce the standard. The `warn` level is typically used for monitoring or gradual rollout, not hard enforcement.

  • ✗

    kubectl label namespace prod pod-security.kubernetes.io/audit=restricted

    Why it's wrong here

    Setting `pod-security.kubernetes.io/audit=restricted` makes the admission controller record the violation in the audit event log while still admitting the Pod. This is a non-blocking, observability-oriented mode that does not affect admission decisions, so non-compliant workloads will run normally. The administrator explicitly needs enforcement, which requires the `enforce` label rather than `audit`.

  • ✓

    kubectl label namespace prod pod-security.kubernetes.io/enforce=restricted

    Why this is correct

    This command correctly applies the `pod-security.kubernetes.io/enforce` label with the value `restricted`, which makes the Pod Security Admission controller reject any Pod that fails the restricted Pod Security Standard. The enforcement is mandatory: the Pod admission request is denied and the API server returns an error. This is the standard, documented mechanism for enforcing a Pod Security Standard at the namespace level.

  • ✗

    kubectl annotate namespace prod security.kubernetes.io/pod-security=restricted

    Why it's wrong here

    This uses an annotation with an incorrect domain. The Pod Security Admission controller recognizes labels under the `pod-security.kubernetes.io/` prefix, not annotations. The key `security.kubernetes.io/pod-security` is not a recognized configuration, so it will be silently ignored and no enforcement will occur. Annotations are metadata only and do not trigger admission behavior in this context.

About these practice questions

This CKS question is part of Courseiva's 845-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKS practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKS exam.