From 01b098de3237b64e5f5a5e16b702129183df5072 Mon Sep 17 00:00:00 2001 From: Gardener Answering Machine <155074045+gardener-answering-machine@users.noreply.github.com> Date: Wed, 10 Sep 2025 13:51:27 +0200 Subject: [PATCH] Add blog simplify-kubernetes-operations-with-mutatingadmissionpolicy --- ...operations-with-mutatingadmissionpolicy.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 website/blog/2025/09/09-10-simplify-kubernetes-operations-with-mutatingadmissionpolicy.md diff --git a/website/blog/2025/09/09-10-simplify-kubernetes-operations-with-mutatingadmissionpolicy.md b/website/blog/2025/09/09-10-simplify-kubernetes-operations-with-mutatingadmissionpolicy.md new file mode 100644 index 000000000..5131679fd --- /dev/null +++ b/website/blog/2025/09/09-10-simplify-kubernetes-operations-with-mutatingadmissionpolicy.md @@ -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) \ No newline at end of file