Courseiva

CKS Minimize Microservice Vulnerabilities Practice Question

Which kubectl command creates a valid webhook configuration that validates pods against a policy?

⚠ Common exam trap

Candidates often confuse ValidatingWebhookConfiguration with MutatingWebhookConfiguration, or assume a generic 'webhookconfiguration.yaml' is valid, but the CKS exam specifically tests the distinction between validation and mutation in admission webhooks.

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 apply -f validatingwebhookconfiguration.yaml

A ValidatingWebhookConfiguration is the Kubernetes resource that intercepts API server requests to validate resources (e.g., pods) against an external policy before they are persisted. The command `kubectl apply -f validatingwebhookconfiguration.yaml` creates this configuration, which triggers a webhook call to an admission webhook server that returns an admission review with an 'allowed' or 'denied' decision.

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 apply -f webhookconfiguration.yaml

    Why it's wrong here

    There is no generic 'WebhookConfiguration' kind in the Kubernetes API; the only admission webhook registration resources are MutatingWebhookConfiguration and ValidatingWebhookConfiguration. A manifest named webhookconfiguration.yaml would either be empty or refer to an unknown kind, causing kubectl apply to reject it with an error such as 'no matches for kind'. Thus it cannot create a valid webhook configuration.

  • ✗

    kubectl apply -f podpreset.yaml

    Why it's wrong here

    PodPreset was an alpha feature that automatically injected fields into Pods, but it was never an admission webhook resource; it was implemented by the PodPreset admission controller and has been deprecated and removed. A podpreset.yaml would define a PodPreset object, not a webhook configuration, so it does not register any webhook endpoint. Applying it would not configure validation or mutation via a webhook.

  • ✗

    kubectl apply -f mutatingwebhookconfiguration.yaml

    Why it's wrong here

    MutatingWebhookConfiguration is a real resource, but it specifically registers mutating admission webhooks that can modify resources before they are persisted. Validation webhooks require a ValidatingWebhookConfiguration, which uses the same AdmissionReview API but expects responses that approve or deny without mutation. If you apply a MutatingWebhookConfiguration while intending to perform validation, the webhook will be invoked for mutation and cannot serve as a validation-only hook.

  • ✓

    kubectl apply -f validatingwebhookconfiguration.yaml

    Why this is correct

    ValidatingWebhookConfiguration is the correct resource type for registering validation webhooks, as it tells the API server which HTTP endpoint to call during admission and whether to allow or deny the request. When you apply a valid validatingwebhookconfiguration.yaml, the API server sends AdmissionReview objects to your configured webhook service and enforces the returned decisions. This is the idiomatic way to add custom validation logic to a cluster.

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

Same concept, more angles

1 more way this is tested on CKS

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Which kubectl command creates a validating webhook configuration that calls an external HTTPS endpoint for pod validation?

easy
  • A.kubectl create admission webhook --validate
  • B.kubectl run webhook --image=...
  • ✓ C.kubectl apply -f webhook.yaml
  • D.kubectl create validatingwebhookconfiguration --url=https://...

Why C: `kubectl apply -f webhook.yaml` is the standard way to create any Kubernetes resource, including a ValidatingWebhookConfiguration, from a YAML manifest. The manifest defines the webhook's client configuration, including the external HTTPS endpoint, CA bundle, and rules for pod validation. There is no dedicated `kubectl create` subcommand for webhooks; the resource must be defined declaratively in a YAML file.

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.