Hi ahd,
Thanks for posting your question in Microsoft Q&A and for the detailed logs and context
We can see two issues here: policy reconciliation errors and denied admission for pods in the error you have shared. please find below points to resolve your issue
1.policy reconciliation errors
The Gatekeeper controller is trying to reconcile your Azure Policy-based constraints but lacks the necessary RBAC permissions to manage ValidatingAdmissionPolicyBindings
at the cluster level. This is a known limitationAzure doesn’t grant Gatekeeper admin rights to delete certain cluster-scoped resources.
- Check the
ClusterRole
andClusterRoleBinding
forgatekeeper-admin
service account ingatekeeper-system
namespace. - Ensure it has
delete, get, list, watch, create, update, patch
permissions onvalidatingadmissionpolicybindings
inadmissionregistration.k8s.io
Without this, Gatekeeper will log errors during reconciliation, but it does not block your cluster, it just means policy enforcement might not fully reconcile.
Refer document: https://learn.microsoft.com/en-us/azure/role-based-access-control/troubleshooting?utm_source=chatgpt.com&tabs
2. Denied admission for pods
- Your Azure Policy for
K8sAzureV2BlockAutomountToken
is actively denying pods that requestautomountServiceAccountToken: true
. - Your namespace exclusion may not be working, which explains why the
ingress
namespace pod is still being blocked.
This could happen if:
- The policy parameters (excluded namespaces) were not set correctly in the constraint.
- There is a mismatch between Azure Policy assignment parameters and Gatekeeper constraint parameters.
- The Helm chart sets
automountServiceAccountToken: true
and Gatekeeper sees it before Azure Policy reconciles the exclusion.
Steps to validate namespace exclusion:
Even though you've excluded the nginx
namespace in the policy assignment, the policy definition itself doesn’t reflect this. Azure Policy only respects exclusions defined in the policy definition, not just in the assignment.
kubectl get K8sAzureV2BlockAutomountToken -A -o yaml | grep -A5 "exemptNamespaces"
1.Ensure nginx
(or ingress
) namespace is listed under exemptNamespaces
or equivalent parameter.
2.If it’s missing, update the Gatekeeper constraint to include that namespace
spec:
parameters:
exemptNamespaces: ["nginx"]
Reapply the constraint and redeploy the pod.
When deploying nginx ingress, explicitly set automountServiceAccountToken: false
in your Helm values if you want to comply with the policy.
You also see container image restrictions:
Container image registry.k8s.io/ingress-nginx/controller:v1.12.3 ... has not been allowed
- This is controlled by
K8sAzureV2ContainerAllowedImages
constraint. - The same rule applies either adjust the constraint to allow the image or run it in dry-run to test.
The logs show "constraint_action":"dryrun"
, meaning the policy is not actively blocking but is reporting violations. So, while the logs look alarming, they’re informational unless enforcement is turned on.
Reconciler errors are temporarily safe to ignore but fixing RBAC is recommended, while denied pod admissions cannot be ignored if pods need to run and require adjusting namespace exclusions or policy parameters.
If you need more inputs on Azure Policy for Kubernetes clusters https://learn.microsoft.com/en-us/azure/governance/policy/concepts/policy-for-kubernetes
I hope this helps you resolve the issue. If you have any further quires, I am happy to assist