AKS Automatic 1.36.5: MutatingWebhookConfiguration denied by aks-managed-require-webhook-protected-namespace-exclusion, matchCondition not auto-injected

Paul Walker 0 Reputation points
2026-11-17T21:23:11.35+00:00

On an AKS Automatic cluster running Kubernetes 1.36.5, I can't create any MutatingWebhookConfiguration unless I add an AKS-specific matchCondition by hand. The denial message says AKS should inject this condition automatically on 1.36+, but that isn't happening.

Environment

  • AKS Automatic, Kubernetes 1.36.5 (control plane and nodes)
  • Region: East US
  • Node image: AKSAzureLinux-V3gen2fips-202610.30.1
  • Azure Policy add-on enabled. It is not the cause: the denial comes from a native ValidatingAdmissionPolicy, not from Gatekeeper.

What happens

Installing the CloudNativePG Helm chart (cloudnative-pg 0.29.1) fails with:

mutatingwebhookconfigurations.admissionregistration.k8s.io "cnpg-mutating-webhook-configuration"
is forbidden: ValidatingAdmissionPolicy 'aks-managed-require-webhook-protected-namespace-exclusion'
with binding 'aks-managed-require-webhook-protected-namespace-exclusion-binding' denied request:
Every webhook in a MutatingWebhookConfiguration must carry the matchCondition
'aks-managed-exclude-system-namespaces', which prevents the webhook from mutating AKS-managed
workloads in protected namespaces such as kube-system. AKS injects it automatically on Kubernetes
1.36.0 and later, so this error on those clusters means the injection did not run: contact support.

Reproduce

kubectl apply --dry-run=server -f <any MutatingWebhookConfiguration> is denied. The same object is accepted once each webhook has:

matchConditions:
  - name: aks-managed-exclude-system-namespaces
    expression: '!(has(request.namespace) && request.namespace in ["kube-system", "aks-istio-system", "aks-static-egress-gateway", "azuresecuritylinuxagent", "aks-istio-egress", "aks-istio-ingress", "fleet-system", "acstor", "azappconfig-system", "azure-extensions-usage-system", "dataprotection-microsoft", "gatekeeper-system", "sc-system"])'

The policy checks that the expression matches its requiredExpression variable exactly, so you need to copy it character for character.

What I checked

  • There are no MutatingAdmissionPolicy or MutatingAdmissionPolicyBinding resources in the cluster.
  • None of the existing mutating webhooks have rules for admissionregistration.k8s.io/mutatingwebhookconfigurations. The ones present are aks-webhook-admission-controller, aks-node-mutating-webhook, safeguards-workload-mutating-webhook, azure-wi-webhook-mutating-webhook-configuration, gatekeeper-mutating-webhook-configuration and vpa-webhook-config.
  • So no injector appears to be deployed.

Workaround

I add the condition through a Helm post-renderer. With Flux it looks like this:

spec:
  postRenderers:
    - kustomize:
        patches:
          - target:
              kind: MutatingWebhookConfiguration
              name: cnpg-mutating-webhook-configuration
            patch: |
              - op: add
                path: /webhooks/0/matchConditions
                value: &aks-exclusion
                  - name: aks-managed-exclude-system-namespaces
                    expression: '<expression above>'
              - op: add
                path: /webhooks/1/matchConditions
                value: *aks-exclusion
              # ...repeat for each webhook in the configuration

Questions

  1. Is anyone else seeing this on AKS Automatic 1.36.x? Is the injector rolled out separately from the policy?
  2. Once injection works, does it leave alone a webhook that already has the condition, or will it add a duplicate? I want to know whether the workaround needs to be removed first.
  3. Will the protected-namespace list in requiredExpression change over time? Because the policy requires an exact match, a hand-added copy would start failing whenever the list changes.
Azure Kubernetes Service
Azure Kubernetes Service

An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.

0 comments No comments

1 answer

Sort by: Newest
  1. Pavan Addepalli 0 Reputation points
    2026-11-19T11:02:14.0666667+00:00

    Your reproduction indicates that the required exclusion is absent when the validating policy evaluates the request. However, it does not establish why the AKS-managed injection failed.

    Microsoft’s AKS release notes for October 25, 2026 explicitly describe protected-system-namespace exclusions for customer mutating admission configurations on AKS Automatic 1.36+. This confirms that the protection is intentional, rather than a CloudNativePG-specific requirement.

    1. Is this a known issue or a separate injector rollout?

    A rollout mismatch is a possibility, not a confirmed diagnosis.

    One important distinction: the absence of a matching MutatingWebhookConfiguration does not prove that the AKS injection component is missing. Kubernetes explicitly excludes MutatingWebhookConfiguration and ValidatingWebhookConfiguration objects from ordinary admission-webhook interception. Therefore, enumerating those webhooks cannot establish how AKS implements this mutation. Microsoft separately documents an AKS-managed admissions enforcer. (v1-36.docs.kubernetes.io)

    Given the error’s explicit instruction to contact support, open an AKS support request with the minimal reproduction, failure timestamp in UTC, cluster version and region, and the validating policy/binding YAML. Ask Microsoft to verify the managed injection path and its compatibility with the deployed validating policy. Microsoft documents Azure support requests as the escalation path for unresolved AKS issues.

    1. Will injection duplicate an existing condition?

    Kubernetes requires match-condition names to be unique within each webhook. That means appending another condition with the same name is not a valid outcome—but this requirement does not establish whether AKS skips, replaces, or otherwise handles an existing condition. I couldn’t find a documented AKS guarantee for that behavior.

    Before removing the workaround, test a copy of the original manifest without the hand-added condition, using an unused configuration name:

    kubectl create --dry-run=server -f .\webhook-probe.yaml -o yaml

    Server-side dry-run processes admission without persisting the object. Once injection is working, the returned YAML should demonstrate whether the required condition was added. Separately test a manifest that already contains the condition to check coexistence on your cluster. (kubernetes.io)

    1. Can the protected-namespace list change?

    Given the exact-string comparison you observed, your concern is valid: if the policy’s required expression changes and AKS does not first update the submitted value, subsequent matching create/update requests containing the old expression would fail.

    Treat the copied expression as a temporary, cluster-specific workaround—not a stable compatibility contract.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.