CKS Minimize Microservice Vulnerabilities Practice Question
An administrator wants to use OPA Gatekeeper to enforce that all pods have a resource limits section defined. Which of the following is the correct combination to implement this policy?
⚠ Common exam trap
The trap is confusing the underlying mechanism (ValidatingWebhookConfiguration) with the user-facing abstraction (ConstraintTemplate + Constraint); candidates who know Gatekeeper uses a webhook often pick the webhook option instead of the correct CRD-based answer.
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
✓
Create a ConstraintTemplate with a Rego policy that checks for 'spec.containers[*].resources.limits', then create a Constraint targeting pods.
OPA Gatekeeper enforces policies via two Kubernetes custom resources: a ConstraintTemplate that contains the Rego policy logic (here, checking that every container has spec.containers[*].resources.limits), and a Constraint that instantiates the template and scopes it to specific resources (e.g., Pods). Together they register a ValidatingWebhookConfiguration behind the scenes to reject noncompliant pods.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Create a NetworkPolicy to block pods without limits.
Why it's wrong here
NetworkPolicy operates at the network layer (L3/L4) and only controls traffic flow between pods, namespaces, or IP blocks via ingress/egress rules. It cannot inspect or validate pod specification fields like resource Limits, and it does not participate in the admission control process. Therefore, a NetworkPolicy cannot block a pod from being created simply because it lacks resource limits; it only affects allowed connectivity after the pod exists.
- ✗
Create a MutatingWebhookConfiguration to add resource limits automatically.
Why it's wrong here
A MutatingWebhookConfiguration automatically injects default values, such as resource limits, into pod specs before they are persisted. While this can make pods compliant, it does not enforce that the user submitted limits—the webhook silently rewrites the request, so the pod is never rejected. The administrator specifically wants enforcement (i.e., denial of non-compliant pods), which requires a ValidatingAdmissionWebhook. OPA Gatekeeper is a validating policy engine, not a mutating one.
- ✗
Create a ValidatingWebhookConfiguration that calls an external service to validate pod limits.
Why it's wrong here
A custom ValidatingWebhookConfiguration that calls an external service could indeed validate resource limits, but this question explicitly asks for OPA Gatekeeper. Gatekeeper provides a declarative, Kubernetes-native policy model using ConstraintTemplate and Constraint CRDs, plus features like audit, dry-run, and versioned policy management. Building a bespoke external webhook would require custom code, deployment, and maintenance, and it would not integrate with Gatekeeper's policy library or reporting, making it a non-idiomatic and far less robust solution.
- ✓
Create a ConstraintTemplate with a Rego policy that checks for 'spec.containers[*].resources.limits', then create a Constraint targeting pods.
Why this is correct
OPA Gatekeeper enforces policies through two CRDs: ConstraintTemplate, which defines a policy using Rego (e.g., checking that `spec.containers[*].resources.limits` exists), and Constraint, which instantiates that template for a specific target like pods. The Rego rule iterates over all containers and generates a violation if any container lacks limits, causing the admission controller to reject the pod. This is the canonical and prescribed method for using Gatekeeper to enforce resource-limit requirements.
Go deeper
Related to this question
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 →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CNCF exam blueprint
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.