All Products
Search
Document Center

Container Service for Kubernetes:Custom CoreDNS configurations

Last Updated:Feb 24, 2025

CoreDNS is the default DNS server of ACK Edge clusters. In ACK Edge clusters, CoreDNS is deployed on each edge as a DaemonSet. This topic describes the default configurations of CoreDNS in ACK Edge clusters and how to configure the hosts plug-in of CoreDNS for extended features.

CoreDNS configuration entry

The coredns ConfigMap in the kube-system namespace is used to manage and configure CoreDNS. Perform the following steps to view the coredns ConfigMap:

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side navigation pane, choose Configurations > ConfigMaps.

  3. In the upper part of the ConfigMap page, set Namespace to kube-system. Then, find the coredns ConfigMap and click Edit YAML in the Actions column to view or modify the coredns ConfigMap.

Default configurations of CoreDNS

The configurations of CoreDNS may vary based on the version of CoreDNS. The following sample code provides an example of the default configurations of CoreDNS 1.11 in ACK Edge clusters.

.:53 {
    errors
    health {
       lameduck 15s
    }
    hosts /etc/edge/tunnel-nodes {
        reload 300ms
        fallthrough
    }        
    ready
    kubeapi
    k8s_event {
      level info error warning
    }

    kubernetes cluster.local in-addr.arpa ip6.arpa {
      pods disabled
      ttl 30
      fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    forward . /etc/resolv.conf {
      prefer_udp
    }
    cache 30
    log
    loop
    reload
    loadbalance
}

The following table describes the fields in the ConfigMap.

Field

Description

errors

Prints errors to standard output (stdout).

health

Generates health check reports for CoreDNS. The default listening port is 8080. This plug-in is used to evaluate the health status of CoreDNS. You can visit http://localhost:8080/health to view the health check report of CoreDNS.

hosts

The hosts plug-in of CoreDNS. This plug-in is used to specify the mapping between domain names and IP addresses.

Important

The hosts configurations in the default domain is specified by the ACK Edge cluster. Do not modify the hosts configurations. If you require custom hosts configurations, see Customize the hosts configurations.

ready

Reports the status of CoreDNS plug-ins. The default listening port is 8181. This plug-in is used to evaluate the readiness of CoreDNS plug-ins. You can visit http://localhost:8181/ready to view the readiness of the CoreDNS plug-ins. After all plug-ins are in the running state, a 200 response code is returned for the readiness of CoreDNS plug-ins.

kubernetes

The kubernetes plug-in of CoreDNS is used to provide DNS resolution for services in an ACK cluster.

prometheus

Exports CoreDNS metrics. You can visit http://localhost:9153/metrics to view CoreDNS metrics in Prometheus format.

forward or proxy

Forwards DNS queries to the predefined DNS server. By default, DNS queries of domain names beyond the cluster domain of Kubernetes are forwarded to the predefined DNS resolver (/etc/resolv.conf). The default configurations are based on the /etc/resolv.conf file on the host.

cache

Enables DNS caching.

loop

Performs loop detection. If a loop is detected, CoreDNS is suspended.

reload

Allows automatic reload of a changed Corefile. After you edit the ConfigMap, wait 2 minutes for the changes to take effect.

loadbalance

Works as a round-robin DNS load balancer to randomize the order of A, AAAA, and MX records in the answer.

Customize the hosts configurations

If you need to map a custom domain name to an IP address, for example, you need to map www.hello.example.com to 127.0.0.1, you can specify the mapping by using the hosts plug-in of CoreDNS. For more information about how to configure the hosts plug-in of CoreDNS, see Plug-ins.

The hosts configurations for the default domain name are specified by the ACK Edge cluster. Therefore, you need to create a new domain name. For example, you can specify example.com:53 to match domain names that are suffixed with example.com. Then, configure the hosts configurations for the new domain name to map www.hello.example.com to 127.0.0.1.

Example

.:53 {
    errors
    health {
       lameduck 15s
    }
    hosts /etc/edge/tunnel-nodes {
        reload 300ms
        fallthrough
    }        
    ready
    kubeapi
    k8s_event {
      level info error warning
    }

    kubernetes cluster.local in-addr.arpa ip6.arpa {
      pods disabled
      ttl 30
      fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    forward . /etc/resolv.conf {
      prefer_udp
    }
    cache 30
    log
    loop
    reload
    loadbalance
}
example.com:53 {   # Specify a new domain name. 
    errors
    hosts {
      127.0.0.1 www.hello.example.com  # Configure domain name resolution. 
      fallthrough
    }
    cache 30
    forward . /etc/resolv.conf {
      prefer_udp
    }
}

For more information about how to configure CoreDNS, see Configure CoreDNS.

References