How do I allow pods to access the IMDS when using IPVS as kube-proxy scheduler?

Orestis Gklavas 0 Reputation points
2025-03-07T12:25:33.73+00:00

We are using an AKS cluster, whose services still use AAD Pod Identity (yes, I know it is deprecated, and yes, it will be migrated to Workload Identity soon).

Due to some performance issues, I decided to try setting kube-proxy to use the IPVS scheduler instead of the default iptables. Indeed, the performance was much higher. However, as I became painfully aware when deploying a nodepool, the NMI pods were unable to contact IMDS to get the required tokens, so my pods would hang at the init state.

I attempted to toy around with kube-proxy IPVS paramters such as excludeCIDRs, with 169.254.169.254/32 as the targt CIDR, but these don't seem to get added to the daemonset's command line params (no configmap is present in the kube-system namespace).

In addition, the "configure kube-proxy" page ( https://learn.microsoft.com/en-us/azure/aks/configure-kube-proxy) points to the AKS Cluster Schema which is supposed to contain the full kube-proxy configuration structure, but I can't seem to be able to find this structure.

Any ideas are welcome. Thanks for taking the time to read through this.

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,316 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pramidha Yathipathi 20 Reputation points Microsoft External Staff
    2025-03-11T07:47:31.21+00:00

    Hi Orestis Gklavas,

    Switching to IPVS improves performance, but it also changes how traffic is routed, which can cause issues with IMDS access. Since AAD Pod Identity relies on NMI pods reaching IMDS (169.254.169.254), you’ll need to make sure this traffic isn’t affected by IPVS rules.

    1.Exclude IMDS from kube-proxy rules

    Since AKS doesn’t use a ConfigMap for kube-proxy, you’ll need to set excludeCIDRs during cluster updates. You can try:

    az aks update \
      --resource-group <your-resource-group> \
      --name <your-cluster-name> \
      --kube-proxy-config '{"mode":"ipvs","excludeCIDRs":["169.254.169.254/32"]}'
    

    However, this might not always work as expected in AKS.

    1. Manually adjust iptables on nodes If the above doesn’t work, you can manually add an iptables rule to ensure traffic to IMDS is handled properly:
    iptables -t nat -A PREROUTING -d 169.254.169.254/32 -j RETURN
    

    This should allow traffic to bypass IPVS.

    3.Run NMI pods with hostNetwork: true

    Modifying the NMI deployment to use hostNetwork: true can help, as it allows the pods to bypass kube-proxy and communicate directly with IMDS.

    Please refer the below documents:

    https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service?tabs=windows

    https://learn.microsoft.com/en-us/azure/aks/imds-restriction

    If the comment was helpful, please don't forget to click "Upvote".

    If you have any further queries, please let us know we are glad to help you.

    Thank You.

    1 person found this answer helpful.
    0 comments No comments

Your answer

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