How to fix AKS policy addon error in Kubernetes
The AKS policy addon error occurs when Azure Policy fails to install, initialize, or enforce policies on your Kubernetes cluster. Common causes include missing prerequisites, Azure Policy addon not enabled, gatekeeper pod failures, or policy constraint violations.
Quick fix
Fixes AKS policy addon error
az aks show -g <resource-group> -n <cluster-name> --query "addonProfiles.azurePolicy"- Verify Azure Policy addon is enabled
- Verify gatekeeper pods are running
- Check webhook certificate and connectivity
- Verify RBAC permissions for Azure Policy addon
az aks show -g <resource-group> -n <cluster-name> --query "addonProfiles.azurePolicy"AKS policy addon error
What this error means
The Azure Policy Add-on extends Gatekeeper v3 (an admission controller webhook for Open Policy Agent) to enforce organizational policies across AKS clusters. When this addon encounters an error, it means the policy enforcement layer failed to initialize or is unable to process policy definitions. This can manifest as installation failures during addon enablement, gatekeeper pods refusing to start, policy constraint violations blocking resource creation, or policy assignments not syncing to the cluster. The addon serves as a control plane for compliance, so failures directly impact your ability to enforce security policies, governance rules, and organizational standards across containerized workloads.
Typical symptoms
- Azure Policy addon installation fails with an error during cluster creation or addon enablement
- Gatekeeper pods in kube-system or gatekeeper-system namespace are not running (CrashLoopBackOff)
- Policy constraints block legitimate workload deployments with "constraint violation" errors
- Policy assignments from Azure Portal do not sync to the cluster (20+ minute delay expected)
- Auditing shows "policy not enforced" or "policy unenforced" status in Azure Policy compliance dashboard
- kubectl get pods -n gatekeeper-system shows pods in Pending, Error, or NotReady state
- kubectl logs on azure-policy or gatekeeper pods reveal RBAC permission errors or configuration issues
Common causes
- Azure Policy addon not enabled on the cluster during creation or via cluster update
- Insufficient Azure RBAC permissions to enable the addon (missing "Microsoft.ContainerService/managedClusters/write")
- Gatekeeper webhook service unable to bind to port 8888 (port conflict or network policy blocking)
- Missing or misconfigured CustomResourceDefinition (CRD) for constraint templates
- Pod security standards (PSS) or network policies blocking gatekeeper pod communication
- Azure Policy extension version incompatibility with Kubernetes version (policy addon requires K8s 1.14+)
- Insufficient cluster resources (CPU/memory) for policy pods to initialize
- Azure Policy attempting to enforce constraint on disabled or incompatible resource types
How to fix "AKS policy addon error"
Check if the addon is installed on your cluster:
az aks show -g <resource-group> -n <cluster-name> --query "addonProfiles.azurePolicy"Expected output should show "enabled": true. If not enabled, install it:
az aks enable-addons -g <resource-group> -n <cluster-name> --addons azure-policyWait 5-10 minutes for the addon to initialize:
kubectl get pods -n kube-system | grep azure-policy
kubectl get pods -n gatekeeper-systemCheck if gatekeeper components are healthy:
kubectl get pods -n gatekeeper-system
kubectl describe pod -n gatekeeper-system # Shows pod events
kubectl logs -n gatekeeper-system --all-containers=true # View logsExpected pods: gatekeeper-audit-*, gatekeeper-controller-manager-*. If pods show CrashLoopBackOff or Error status:
kubectl logs -n gatekeeper-system -l control-plane=controller-manager --tail=50Look for RBAC, webhook binding, or resource contention errors.
Azure Policy uses a webhook to intercept API requests. Verify it's configured:
kubectl get ValidatingWebhookConfiguration -n gatekeeper-system
kubectl describe ValidatingWebhookConfiguration gatekeeper-validating-webhook-configurationVerify the webhook service is accessible:
kubectl get service -n gatekeeper-system
kubectl port-forward -n gatekeeper-system svc/gatekeeper-webhook-service 8888:8888If webhook certificate is expired (common after long cluster idle periods), redeploy the addon:
az aks disable-addons -g <resource-group> -n <cluster-name> --addons azure-policy
sleep 60
az aks enable-addons -g <resource-group> -n <cluster-name> --addons azure-policyThe addon service principal needs cluster role bindings. Check:
kubectl get clusterrolebinding | grep azure-policy
kubectl get clusterrole | grep azure-policyIf missing, the addon cannot function. Verify you have Azure RBAC to enable addons:
az aks check-acl --resource-group <resource-group> --name <cluster-name>You need "Microsoft.ContainerService/managedClusters/write" permission. If permission denied:
- Contact subscription owner to grant "AKS Cluster Admin" or "Contributor" role
- Or use az aks update after role assignment:
az aks update -g <resource-group> -n <cluster-name>Network policies or Pod Security Standards (PSS) may block gatekeeper. Verify ingress to webhook:
kubectl get networkpolicy -n gatekeeper-system
kubectl describe pod -n gatekeeper-system -l control-plane=controller-manager | grep -i "network\|security"If PSS is enforcing restricted mode, it may block the webhook:
kubectl describe namespace gatekeeper-system | grep pod-securityIf restricted, temporarily relax for gatekeeper namespace:
kubectl label namespace gatekeeper-system pod-security.kubernetes.io/enforce=baseline --overwriteThen redeploy gatekeeper.
Check if constraint templates are deployed:
kubectl get constrainttemplates
kubectl describe constrainttemplate K8sRequiredLabels # Example templateIf templates missing, policy enforcement cannot start. For policy assignments in Azure:
az policy assignment list --scope /subscriptions/<subscription-id>/resourceGroups/<rg>/providers/Microsoft.ContainerService/managedClusters/<cluster-name>Assignments take up to 20 minutes to sync. If sync fails:
kubectl logs -n kube-system -l app=azure-policy --tail=100Look for "failed to apply" or "constraint not found" errors.
Azure Policy addon requires Kubernetes 1.14+. Check:
kubectl version --short
az aks show -g <resource-group> -n <cluster-name> --query kubernetesVersionIf older than 1.14, upgrade cluster:
az aks upgrade -g <resource-group> -n <cluster-name> --kubernetes-version 1.27Note: Kubernetes 1.27+ has long-term support (LTS) and is recommended for production. After upgrade, re-enable the addon if needed.
If addon still fails after checks, perform a clean redeploy:
# 1. Disable addon
az aks disable-addons -g <resource-group> -n <cluster-name> --addons azure-policy
# 2. Wait for cleanup
sleep 120
# 3. Verify removed
kubectl get pods -n gatekeeper-system # Should be empty
kubectl get pods -n kube-system | grep azure-policy # Should be gone
# 4. Re-enable
az aks enable-addons -g <resource-group> -n <cluster-name> --addons azure-policy
# 5. Monitor initialization
watch kubectl get pods -n gatekeeper-systemInitialization can take 5-15 minutes. Watch for all pods to reach "Running" state.
For persistent issues, enable Azure diagnostic logs:
az monitor diagnostic-settings create \
--name aks-policy-diags \
--resource /subscriptions/<subscription-id>/resourceGroups/<rg>/providers/Microsoft.ContainerService/managedClusters/<cluster-name> \
--logs '[{"category": "cluster-autoscaler", "enabled": true}]' \
--workspace <log-analytics-workspace-id>Then query logs in Log Analytics:
ContainerLog
| where TimeGenerated > ago(1h)
| where LogEntry contains "azure-policy" or LogEntry contains "gatekeeper"
| project TimeGenerated, Pod, LogEntryThis helps identify root causes in complex scenarios.
Advanced notes
In production, policy addon failures can block security-critical deployments. Always test policy changes in non-prod clusters first. Policy assignments syncing takes 20+ minutes; do not immediately retry if assignment appears not applied. For distros like AKS on Azure Stack HCI, ensure proper network routing to webhook endpoint. When combining with Pod Security Standards (PSS), note that gatekeeper operates at admission control level while PSS operates at pod security levelβorder of enforcement matters. For air-gapped clusters, ensure container images for azure-policy and gatekeeper are cached in your private registry. Azure Policy for Kubernetes uses OPA (Open Policy Agent) Rego language for policy logic; invalid Rego constraints will fail silently. For cost-sensitive deployments, note that audit-mode policies still consume gatekeeper resources even if not enforcing.
Frequently asked questions
- What does "AKS policy addon error" mean?
- The Azure Policy Add-on extends Gatekeeper v3 (an admission controller webhook for Open Policy Agent) to enforce organizational policies across AKS clusters. When this addon encounters an error, it means the policy enforcement layer failed to initialize or is unable to process policy definitions. This can manifest as installation failures during addon enablement, gatekeeper pods refusing to start, policy constraint violations blocking resource creation, or policy assignments not syncing to the cluster.
- How do I fix "AKS policy addon error"?
- The AKS policy addon error occurs when Azure Policy fails to install, initialize, or enforce policies on your Kubernetes cluster. Common causes include missing prerequisites, Azure Policy addon not enabled, gatekeeper pod failures, or policy constraint violations.
- What causes "AKS policy addon error"?
- Azure Policy addon not enabled on the cluster during creation or via cluster update Insufficient Azure RBAC permissions to enable the addon (missing "Microsoft.ContainerService/managedClusters/write") Gatekeeper webhook service unable to bind to port 8888 (port conflict or network policy blocking)
- Is the "AKS policy addon error" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- πKubernetes Official Documentation
- πMicrosoft Docs: troubleshoot azure policy add on aks(Official Docs)
- πMicrosoft Docs: use azure policy(Official Docs)
- πMicrosoft Docs: policy for kubernetes(Official Docs)
- πMicrosoft Docs: policy reference(Official Docs)
- π