Custom DNS settings

Add stub domains and other DNS settings to your cluster’s CoreDNS

Clusters on Kubernetes 1.35 and later run a CoreDNS that we manage. You can add your own DNS settings to it, such as a stub domain forwarded to your own DNS servers, from inside your cluster. You don’t need to change the cluster spec or contact support.

How it works

CoreDNS reads an optional ConfigMap named coredns-custom in the kube-system namespace. The ConfigMap is yours: you create, change and delete it, and our upgrades never touch it. Without it, CoreDNS runs with our defaults.

Each key in the ConfigMap must end in one of these suffixes:

  • .server: a complete CoreDNS server block, for example a stub domain. Use this for most cases.
  • .override: plugin lines added to the main server block that answers all other names. Note that CoreDNS runs plugins in a fixed order, not in the order they appear.

Keys with any other suffix are ignored.

Add a stub domain

This example sends every lookup for corp.example and its subdomains to your DNS servers at 10.1.2.3 and 10.1.2.4:

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  corp.server: |
    corp.example:53 {
        errors
        cache 30
        forward . 10.1.2.3 10.1.2.4
    }

Apply it:

kubectl apply -f coredns-custom.yaml

CoreDNS picks up the change within about a minute, without a restart. Check it from a pod:

kubectl run dnstest --rm -it --restart=Never --image=busybox:1.37 -- nslookup host.corp.example

The DNS servers you forward to must be reachable from the cluster’s nodes.

Remove your settings

Delete the ConfigMap, or the key you no longer want:

kubectl -n kube-system delete configmap coredns-custom

CoreDNS goes back to the defaults within about a minute.

Important: test your changes

After every change, check the CoreDNS logs for errors:

kubectl -n kube-system logs -l k8s-app=kube-dns --since=2m | grep -i error

If CoreDNS pods do not start, fix or delete coredns-custom first.