⎈ k8s knowledge compiler

Autoscale the DNS Service in a Cluster [page]deterministic

tasksnetworking

This page shows how to enable and configure autoscaling of the DNS service in your Kubernetes cluster.

##

*

* This guide assumes your nodes use the AMD64 or Intel 64 CPU architecture.

* Make sure [Kubernetes DNS](/docs/concepts/services-networking/dns-pod-service/) is enabled.

## Determine whether DNS horizontal autoscaling is already enabled {#determining-whether-dns-horizontal-autoscaling-is-already-enabled}

List the [Deployments](#gloss:deployment) in your cluster in the kube-system [namespace](#gloss:namespace):

```shell kubectl get deployment --namespace=kube-system ```

The output is similar to this:

NAME READY UP-TO-DATE AVAILABLE AGE ... kube-dns-autoscaler 1/1 1 1 ... ...

If you see "kube-dns-autoscaler" in the output, DNS horizontal autoscaling is already enabled, and you can skip to [Tuning autoscaling parameters](#tuning-autoscaling-parameters).

## Get the name of your DNS Deployment {#find-scaling-target}

List the DNS deployments in your cluster in the kube-system namespace:

```shell kubectl get deployment -l k8s-app=kube-dns --namespace=kube-system ```

The output is similar to this:

NAME READY UP-TO-DATE AVAILABLE AGE ... coredns 2/2 2 2 ... ...

If you don't see a Deployment for DNS services, you can also look for it by name:

```shell kubectl get deployment --namespace=kube-system ```

and look for a deployment named `coredns` or `kube-dns`.

Your scale target is

Deployment/<your-deployment-name>

where `<your-deployment-name>` is the name of your DNS Deployment. For example, if the name of your Deployment for DNS is coredns, your scale target is Deployment/coredns.

> Note: CoreDNS is the default DNS service for Kubernetes. CoreDNS sets the label `k8s-app=kube-dns` so that it can work in clusters that originally used kube-dns.

## Enable DNS horizontal autoscaling {#enablng-dns-horizontal-autoscaling}

In this section, you create a new Deployment. The Pods in the Deployment run a container based on the `cluster-proportional-autoscaler-amd64` image.

Create a file named `dns-horizontal-autoscaler.yaml` with this content:

In the file, replace `<SCALE_TARGET>` with your scale target.

Go to the directory that contains your configuration file, and enter this command to create the Deployment:

```shell kubectl apply -f dns-horizontal-autoscaler.yaml ```

The output of a successful command is:

deployment.apps/kube-dns-autoscaler created

DNS horizontal autoscaling is now enabled.

## Tune DNS autoscaling parameters {#tuning-autoscaling-parameters}

Verify that the kube-dns-autoscaler [ConfigMap](#gloss:configmap) exists:

```shell kubectl get configmap --namespace=kube-system ```

The output is similar to this:

NAME DATA AGE ... kube-dns-autoscaler 1 ... ...

Modify the data in the ConfigMap:

```shell kubectl edit configmap kube-dns-autoscaler --namespace=kube-system ```

Look for this line:

```yaml linear: '{"coresPerReplica":256,"min":1,"nodesPerReplica":16}' ```

Modify the fields according to your needs. The "min" field indicates the minimal number of DNS backends. The actual number of backends is calculated using this equation:

replicas = max( ceil( cores × 1/coresPerReplica ) , ceil( nodes × 1/nodesPerReplica ) )

Note that the values of both `coresPerReplica` and `nodesPerReplica` are floats.

The idea is that when a cluster is using nodes that have many cores, `coresPerReplica` dominates. When a cluster is using nodes that have fewer cores, `nodesPerReplica` dominates.

There are other supported scaling patterns. For details, see [cluster-proportional-autoscaler](https://github.com/kubernetes-sigs/cluster-proportional-autoscaler).

## Disable DNS horizontal autoscaling

There are a few options for tuning DNS horizontal autoscaling. Which option to use depends on different conditions.

### O …(trimmed)

Sources

tasks/administer-cluster/dns-horizontal-autoscaling.md · docAutoscale the DNS Service in a Cluster

Related (15)

references DeploymentDeployments conf=1
references Namespacenamespace conf=1
references ConfigMapConfigMap conf=1
part_of {{% heading "prerequisites" %}}describes conf=1
part_of Disable DNS horizontal autoscalingdescribes conf=1
part_of {{% heading "whatsnext" %}}describes conf=1
api_for Scaledocuments API object conf=1

← all Docs