CoreDNS is a DNS server that provides domain name resolution for Kubernetes clusters through chained plugins.
CoreDNS is an open-source software and has been a part of CNCF. It provides a means for cloud services to discover each other in cloud native deployments. Each of the plugins chained by CoreDNS provides a particular DNS function. You can integrate CoreDNS with only the plugins you need to make it fast, efficient, and flexible. When used in a Kubernetes cluster, CoreDNS can automatically discover services in the cluster and provide domain name resolution for these services. By working with DNS servers, CoreDNS can resolve external domain names for workloads in a cluster.
This add-on is installed by default during cluster creation.
Kubernetes backs CoreDNS as the official default DNS for all clusters going forward.
CoreDNS official website: https://coredns.io/
Open-source community: https://github.com/coredns/coredns
For details, see DNS.
To run CoreDNS properly or upgrade CoreDNS in a cluster, ensure the number of available nodes in the cluster is greater than or equal to the number of CoreDNS instances and all CoreDNS instances are running. Otherwise, the add-on will malfunction or the upgrade will fail.
This add-on has been installed by default. If it is uninstalled due to some reasons, you can reinstall it by performing the following steps:
The small one can handle up to 2500 external and 10,000 internal domain names QPS. The medium specification can handle up to 5000 external and 20,000 internal domain names QPS. The large specification can handle up to 10,000 external and 40,000 internal domain names QPS.
Nodes | Recommended QPS | Pods | Requested vCPUs | vCPU Limit | Requested Memory | Memory Limit |
|---|---|---|---|---|---|---|
50 | 2500 | 2 | 500m | 500m | 512 MiB | 512 MiB |
200 | 5000 | 2 | 1000m | 1000m | 1024 MiB | 1024 MiB |
1000 | 10000 | 2 | 2000m | 2000m | 2048 MiB | 2048 MiB |
2000 | 20000 | 4 | 2000m | 2000m | 2048 MiB | 2048 MiB |
Parameter | Description |
|---|---|
Stub Domain | A domain name server for a custom domain name. The format is a key-value pair. The key is a domain name suffix, and the value is one or more DNS IP addresses, for example, acme.local -- 1.2.3.4,6.7.8.9. For details, see Configuring the Stub Domain for CoreDNS. CAUTION: Uppercase letters are not allowed in custom domain names. |
Extended Parameter Settings |
Example:
|
Plugin Name | Type | Description |
|---|---|---|
bind | Default configuration | Host IP address listened by CoreDNS. Retain the default value {$POD_IP}. For details, see bind. |
cache | Default configuration | Enables DNS cache. For details, see cache. If the add-on version is 1.25.10 or later, the servfail cache can be disabled. To disable the servfail cache, set configBlock to servfail 0. Otherwise, the unit of the servfail cache is second and cannot be omitted. |
errors | Default configuration | Errors are logged to stdout. For details, see errors. |
health | Default configuration | Health check for CoreDNS. {$POD_IP}:8080 is listened to. Retain the default setting. Otherwise, the CoreDNS health check will fail and the add-on will restart repeatedly. For details, see health. |
ready | Default configuration | Whether the backend server is ready to receive traffic. {$POD_IP}:8081 is listened to. If the backend server is not ready, CoreDNS will suspend DNS resolution until the backend server is ready. For details, see ready. |
kubernetes | Default configuration | CoreDNS Kubernetes plugin, which provides the service parsing capability in a cluster. For details, see kubernetes. |
loadbalance | Default configuration | Round-robin DNS load balancer that randomizes the order of A, AAAA, and MX records in an answer. For details, see loadbalance. |
prometheus | Default configuration | API for obtaining CoreDNS metrics. {$POD_IP}:9153 is listened to by default. Retain the default setting. Otherwise, Prometheus cannot collect CoreDNS metrics. For details, see Prometheus. |
forward | Default configuration | Forwards any queries that are not within the cluster domain of Kubernetes to predefined resolvers (/etc/resolv.conf). For details, see forward. |
reload | Default configuration | Automatically reloads modified Corefiles. After you modify a ConfigMap, wait for two minutes for the modification to take effect. For details, see reload. |
log | Extended configuration | Enables CoreDNS logging. For details, see log. The following is an example:
|
template | Extended configuration | A quick response template, where AAAA indicates an IPv6 request. If NXDOMAIN is returned in an rcode response, no IPv6 resolution result is returned. For details, see template. The following is an example:
|
Parameter | Description |
|---|---|
Multi-AZ Deployment |
|
Node Affinity |
|
Toleration | Using both taints and tolerations allows (not forcibly) the add-on Deployment to be scheduled to a node with the matching taints, and controls the Deployment eviction policies after the node where the Deployment is located is tainted. The add-on adds the default tolerance policy for the node.kubernetes.io/not-ready and node.kubernetes.io/unreachable taints, respectively. The tolerance time window is 60s. For details, see Configuring Tolerance Policies. |
Component | Description | Resource Type |
|---|---|---|
CoreDNS | DNS server for clusters | Deployment |
If you install the CoreDNS add-on, the Corefile view configuration is not available. This configuration is supported only when you are editing or upgrading the add-on.
Once the function is enabled, the ConfigMap of CoreDNS in the kube-system namespace will be directly configured in the Corefile format. Any existing stub domain configurations and parameters such as parameterSyncStrategy, servers, and upstream_nameservers in the advanced configuration will no longer be in effect. It is important to verify that the Corefile configuration is accurate.
For description of the Corefile format, see Configuration.
DNS policies can be configured for each pod. Kubernetes supports DNS policies Default, ClusterFirst, ClusterFirstWithHostNet, and None. For details, see DNS for Services and Pods. These policies are specified in the dnsPolicy field in the pod-specific.
Routing
Without stub domain configurations: Any query that does not match the configured cluster domain suffix, such as www.kubernetes.io, is forwarded to the upstream DNS server inherited from the node.
With stub domain configurations: If stub domains and upstream DNS servers are configured, DNS queries are routed according to the following flow:
Figure 1 Routing
