Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article explains how to configure and customize CoreDNS autoscaling in Azure Kubernetes Service (AKS) clusters.
Configure CoreDNS horizontal pod scaling
Due to the elastic nature of AKS, it's common to experience sudden spikes in DNS traffic within your clusters. These spikes can lead to an increase in memory consumption by CoreDNS pods. In some cases, this increased memory consumption can cause Out of memory issues.
To preempt this issue, AKS clusters autoscale CoreDNS pods to reduce memory usage per pod. The default settings for this autoscaling logic are stored in the coredns-autoscaler ConfigMap. However, you might observe that the default autoscaling of CoreDNS pods isn't always aggressive enough to prevent Out of memory issues for your CoreDNS pods. In this case, you can directly modify the coredns-autoscaler ConfigMap. Keep in mind that simply increasing the number of CoreDNS pods without addressing the root cause of the Out of memory issue might only provide a temporary fix. If there's not enough memory available across the nodes where the CoreDNS pods are running, increasing the number of CoreDNS pods won't help. You might need to investigate further and implement appropriate solutions such as optimizing resource usage, adjusting resource requests and limits, or adding more memory to the nodes.
CoreDNS uses the horizontal cluster proportional autoscaler for pod autoscaling. You can edit the coredns-autoscaler to configure the scaling logic for the number of CoreDNS pods. The coredns-autoscaler ConfigMap currently supports two different ConfigMap key values: linear and ladder, which correspond to two supported control modes.
- The
linearcontroller yields a number of replicas in [min,max] range equivalent tomax( ceil( cores * 1/coresPerReplica ) , ceil( nodes * 1/nodesPerReplica ) ). - The
laddercontroller calculates the number of replicas by consulting two different step functions, one for core scaling and another for node scaling, yielding the max of the two replica values.
For more information on the control modes and ConfigMap format, see the upstream documentation.
Important
We recommend a minimum of two CoreDNS pod replicas per cluster.
View the current coredns-autoscaler ConfigMap
Get the current
coredns-autoscalerConfigMap using thekubectl get configmapscommand.kubectl get configmap coredns-autoscaler --namespace kube-system --output yamlYour output should resemble the following example output:
apiVersion: v1 data: ladder: '{"coresToReplicas":[[1,2],[512,3],[1024,4],[2048,5]],"nodesToReplicas":[[1,2],[8,3],[16,4],[32,5]]}' kind: ConfigMap metadata: name: coredns-autoscaler namespace: kube-system resourceVersion: "..." creationTimestamp: "..."
Note
The configuration provided serves as a potential starting point, but you should customize the values based on your specific cluster requirements and DNS traffic patterns. One way to determine the appropriate number of replicas for your environment is to use the linear scaling formula: replicas = max( ceil( cores * 1/coresPerReplica ) , ceil( nodes * 1/nodesPerReplica ) ) to determine replica counts based on core / node count in the cluster.
Next steps
To learn how to troubleshoot CoreDNS issues, see Troubleshoot issues with CoreDNS on Azure Kubernetes Service (AKS).