How can I set a custom cloud-init script to run on the AKS agent pool?

Yaron Bar 0 Reputation points
2025-04-29T08:48:03.8366667+00:00

I would like to add some specific configuration to my AKS agent pool.

How do I pass a cloud-init script to the agent pool creation request?

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,385 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. UJTyagi-MSFT 930 Reputation points Microsoft Employee
    2025-04-29T09:51:53.91+00:00

    Hi @Yaron Bar

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    Kindly note AKS manages the lifecycle and operations of agent nodes on your behalf and modifying the IaaS resources associated with the agent nodes is not supported.

    An example of an unsupported operation is customizing a node pool virtual machine scale set by manually changing configurations in the Azure portal or from the API.

    However, when you create an AKS cluster or add a node pool to your cluster, you can customize a subset of commonly used OS and kubelet settings which are listed on the below page

    https://learn.microsoft.com/en-us/azure/aks/custom-node-configuration?tabs=linux-node-pools

    While cloud-init is commonly used on Linux VMs, it is not directly supported for AKS node pools. Instead, you should use Kubernetes-native mechanisms like Daemon Sets to achieve similar functionality. The requirement is listed on below page

    https://learn.microsoft.com/en-us/azure/aks/support-policies#user-customization-of-agent-nodes

    Refer the daemon set definition on below page -

    https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/

    Kindly note Azure support cannot help troubleshooting or diagnose modifications that makes the node unavailable due to a custom deployed daemon set.


    If the below answer addressed your query, please don’t forget to click "Accept the answer" and Up-Vote for the same, which might be beneficial to other community members reading this thread. And, if you have any further query do let us know.

    Thanks,


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.