WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Kubernetes · Guru · question 94 of 100

Explain the role of Kubernetes Admission Webhooks, their types (Validating and Mutating), and how they can be used to implement custom validation and mutation logic.?

📕 Buy this interview preparation book: 100 Kubernetes questions & answers — PDF + EPUB for $5

Kubernetes Admission Webhooks are a mechanism for intercepting requests to the Kubernetes API server before they are persisted to etcd. Admission Webhooks can be used to apply custom validation and mutation logic to Kubernetes resources, ensuring that only valid resources are deployed to the cluster. Admission Webhooks can be divided into two types: Validating and Mutating.

Validating Admission Webhooks intercept requests to the Kubernetes API server and can either accept or reject the request based on whether the request passes a set of validation rules. This can be useful for enforcing business policies or ensuring that certain security constraints are met. For example, a Validating Admission Webhook could be used to ensure that all Kubernetes resources contain a specific label or annotation, or to check that a user is authorized to make a particular request.

Mutating Admission Webhooks, on the other hand, can modify the request before it is persisted to etcd. This can be useful for applying default values or performing transformations on the request. For example, a Mutating Admission Webhook could be used to automatically add a label or annotation to all Kubernetes resources, or to convert a request from one API version to another.

To implement a custom Admission Webhook, you need to create a web service that receives requests from the Kubernetes API server. The web service should implement the appropriate Validating or Mutating Admission Webhook interface, which defines the methods for validating or mutating the request. The web service should also expose an HTTPS endpoint with a signed certificate that can be trusted by the Kubernetes API server.

Once the web service is deployed, you can register it with the Kubernetes API server by creating a ValidatingWebhookConfiguration or MutatingWebhookConfiguration object. These objects define the endpoint of the web service and the resources and operations that the Admission Webhook should intercept. When the Kubernetes API server receives a request that matches the configuration, it sends the request to the Admission Webhook for validation or mutation.

In conclusion, Admission Webhooks provide a powerful mechanism for customizing the behavior of the Kubernetes API server. They can be used to implement custom validation and mutation logic, enforce business policies, or apply default values and transformations to Kubernetes resources.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Kubernetes interview — then scores it.
📞 Practice Kubernetes — free 15 min
📕 Buy this interview preparation book: 100 Kubernetes questions & answers — PDF + EPUB for $5

All 100 Kubernetes questions · All topics