Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "Simplify Kubernetes Operations with MutatingAdmissionPolicy"
linkTitle: "Simplify Kubernetes Operations with MutatingAdmissionPolicy"
newsSubtitle: September 10, 2025
publishdate: 2025-09-10
authors:
- avatar: https://avatars.githubusercontent.com/voelzmo
login: voelzmo
name: Marco Voelz
aliases: ["/blog/2025/09/10/simplify-kubernetes-operations-with-mutatingadmissionpolicy"]
---

Making a quick, one-off change to a running Kubernetes resource can be challenging. While controllers work tirelessly to reconcile the cluster to its desired state, this is precisely what you want to avoid for temporary modifications, such as increasing a component's log level during an incident. Traditionally, this required deploying a mutating admission webhook, which often introduces significant operational overhead and complexity.

Gardener is embracing a simpler, more integrated solution: the native Kubernetes `MutatingAdmissionPolicy`.

### A Native Alternative to Mutating Webhooks

`MutatingAdmissionPolicy` is a Kubernetes-native feature, now in beta, that provides the power of mutating webhooks without the need to run a separate webhook server. The policy logic runs directly within the Kubernetes API server process, offering a more lightweight and performant way to modify resources during admission.

These policies are defined using the [Common Expression Language (CEL)](https://github.com/google/cel-spec), a purpose-built language designed for safety and efficiency. The API server can evaluate the cost of a CEL expression before execution, preventing complex policies from impacting its performance.

### The Building Blocks of a Policy

A mutating admission policy is composed of three key resources:

1. **`MutatingAdmissionPolicy`**: This object defines the abstract logic of the mutation. For example, it might specify how to change a specific command-line argument in a container.
2. **`MutatingAdmissionPolicyBinding`**: This binding connects a policy to a set of resources. It uses match criteria (like namespace or resource labels) to define the scope of the policy, determining which objects it applies to.
3. **Parameter Resource (Optional)**: For greater flexibility, a policy can be parameterized. A separate resource, like a `ConfigMap`, can provide concrete values (e.g., the name of a container and the desired log level) to the abstract policy. This allows the same policy logic to be reused for different scenarios.

### Defining Mutations: JSONPatch and ApplyConfiguration

Mutations can be expressed in two ways:

* **`JSONPatch`**: This familiar format, also used by traditional webhooks, allows for precise and complex modifications, such as replacing a specific value within an array.
* **`ApplyConfiguration`**: This more concise, CEL-based syntax is ideal for simpler changes, like adding a label or injecting a sidecar container.

For many everyday operational tasks, such as modifying an existing argument in a container's command list, `JSONPatch` provides the necessary control to target and change specific elements.

By integrating `MutatingAdmissionPolicy`, Gardener provides a powerful and efficient tool for operators to manage clusters. This native approach reduces complexity, improves performance, and makes everyday operational tasks simpler and more reliable.

### Further Reading

* **Kubernetes Documentation**: [Mutating Admission Policy](https://kubernetes.io/docs/reference/access-authn-authz/mutating-admission-policy/)
* **Watch the Talk**: [Recording on YouTube](https://youtu.be/aUCxInp-yaA?t=1686)