Skip to main content

Autoscaling CoreDNS

CoreDNS is the default DNS service for Kubernetes that runs in Pods with the label k8s-app=kube-dns. In this lab exercise we'll scale CoreDNS based on the number of schedulable nodes and cores of our cluster. Cluster Proportional Autoscaler will resize the number of CoreDNS replicas.

info

Amazon EKS offers the ability to automatically scale CoreDNS via the EKS addon, which is the recommended path for production use. The material covered in this lab is for educational purposes.

First lets install CPA using its Helm chart. We'll use the following values.yaml file to configure CPA:

~/environment/eks-workshop/modules/autoscaling/workloads/cpa/values.yaml
options:
target: deployment/coredns
namespace: kube-system

config:
linear:
nodesPerReplica: 2
min: 2
max: 6
preventSinglePointFailure: true
includeUnschedulableNodes: true
A

Target the deployment coredns

B

Add a replica for every 2 worker nodes in the cluster

C

Always run at least 2 replicas

D

Do not scale to more than 6 replicas

caution

The configuration above should not be considered best practice for automatically scaling CoreDNS, it is an example that is easy to demonstrate for the purposes of the workshop.

Install the chart:

~$helm repo add cluster-proportional-autoscaler https://kubernetes-sigs.github.io/cluster-proportional-autoscaler
~$helm upgrade --install cluster-proportional-autoscaler cluster-proportional-autoscaler/cluster-proportional-autoscaler \
--namespace kube-system \
--version "${CPA_CHART_VERSION}" \
--set "image.tag=v${CPA_VERSION}" \
--values ~/environment/eks-workshop/modules/autoscaling/workloads/cpa/values.yaml \
--wait
NAME: cluster-proportional-autoscaler
LAST DEPLOYED: [...]
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None

This will create a Deployment in the kube-system namespace which we can inspect:

~$kubectl get deployment cluster-proportional-autoscaler -n kube-system
NAME                              READY   UP-TO-DATE   AVAILABLE   AGE
cluster-proportional-autoscaler   1/1     1            1           92s