Home Explore Blog CI



kubernetes

2nd chunk of `content/en/docs/tasks/administer-cluster/dns-horizontal-autoscaling.md`
d057c922e8816326554cd425699bc077014189fdc0563c95000000010000090b
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 {{< glossary_tooltip text="ConfigMap" term_id="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.

### Option 1: Scale down the kube-dns-autoscaler deployment to 0 replicas

This option works for all situations. Enter this command:

```shell
kubectl scale deployment --replicas=0 kube-dns-autoscaler --namespace=kube-system
```

The output is:

    deployment.apps/kube-dns-autoscaler scaled

Verify that the replica count is zero:

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

The output displays 0 in the DESIRED and CURRENT columns:

    NAME                                  DESIRED   CURRENT   READY   AGE

Title: Completing and Tuning DNS Horizontal Autoscaling
Summary
After creating the autoscaler Deployment, the guide instructs users to verify and tune autoscaling parameters by modifying the kube-dns-autoscaler ConfigMap. It explains the parameters 'coresPerReplica', 'min', and 'nodesPerReplica', and provides the formula for calculating the number of replicas. It also mentions other scaling patterns supported by cluster-proportional-autoscaler. Finally, it details how to disable DNS horizontal autoscaling by scaling down the kube-dns-autoscaler Deployment to 0 replicas.