In the world of Kubernetes on Azure, there’s been a longstanding default: any pod in your AKS cluster can query the Azure Instance Metadata Service (IMDS). That’s powerful — but also risky. Today, Microsoft introduces a preview feature that lets you block pod access to IMDS, tightening your cluster’s security boundaries.
Why Restrict IMDS?
IMDS is a REST API that provides VM metadata: VM specs, networking, upcoming maintenance events, and (critically) identity tokens. Because it’s accessible by default (via IP 169.254.169.254
), a pod that’s compromised or misbehaving could exploit this to pull sensitive information or impersonate the node’s identity. That’s a serious threat.
By limiting which pods can reach IMDS, you reduce the “blast radius” of potential vulnerabilities.
How the Restriction Works (Preview)
- Non host network pods (
hostNetwork: false
) lose access to IMDS entirely once restriction is enabled. - Host network pods (
hostNetwork: true
) retain access (they share the same network space as the node). - Azure implements this via iptables rules on the node to block traffic from non-host pods.
- Tampering with iptables (e.g. via SSH or privileged containers) can break enforcement, so best practices like disabling SSH or avoiding privileged pods come into play.
Limitations & Considerations
Because this is still in preview, there are a number of tradeoffs:
- Many AKS add-ons do not support IMDS restriction (e.g. Azure Monitor, Application Gateway Ingress, Flux/GitOps, Azure Policy, etc.).
- Windows node pools aren’t supported yet.
- Enabling restriction on a cluster that uses unsupported add-ons will fail.
- After enabling or disabling, you must reimage the nodes (e.g. via
az aks upgrade --node-image-only
) to apply or remove the iptables rules. - The feature is opt-in and isn’t backed by an SLA or warranty.
Getting Started: Enabling IMDS Restriction
- Use Azure CLI 2.61.0+ and install or update
aks-preview
. - Register the IMDSRestrictionPreview feature and refresh the ContainerService provider.
- Ensure OIDC issuer is enabled on your cluster (required).
- To create a new cluster with this feature:
az aks create ... --enable-imds-restriction
- To enable it on an existing cluster:
az aks update ... --enable-imds-restriction
Then reimage nodes for enforcement. - To verify, deploy test pods with and without
hostNetwork: true
and attempt tocurl
IMDS — the non-host pods should fail, the host pods should succeed. - To disable, run
az aks update --disable-imds-restriction
and reimage.
Final Thoughts
This new capability gives AKS users an additional layer of defense: limiting which pods can access VM metadata and identities.
Reference: https://learn.microsoft.com/en-us/azure/aks/imds-restriction
Maxime.