The coredns add-on is a DNS server that provides domain name resolution services for Kubernetes clusters. coredns chains plug-ins to provide additional features.
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 plug-ins chained by coredns provides a particular DNS function. You can integrate coredns with only the plug-ins 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 server, coredns can resolve external domain names for workloads in a cluster.
coredns is a system resource add-on. It is installed by default when a cluster of Kubernetes v1.11 or later is created.
Kubernetes v1.11 and later back 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
When coredns is running properly or being upgraded, ensure that the number of available nodes is greater than or equal to the number of coredns instances and all coredns instances are running. Otherwise, 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:
Parameter |
Description |
---|---|
Add-on Specifications |
Concurrent domain name resolution ability. Select add-on specifications that best fit your needs. If you select Custom qps, the domain name resolution QPS provided by CoreDNS is positively correlated with the CPU consumption. Adjust the number of pods and container CPU/memory quotas as required. |
Pods |
Number of pods that will be created to match the selected add-on specifications. |
Multi AZ |
|
Containers |
CPU and memory quotas of the container allowed for the selected add-on specifications. |
Parameters |
Example: { "servers": [ { "plugins": [ { "name": "bind", "parameters": "{$POD_IP}" }, { "name": "cache", "parameters": 30 }, { "name": "errors" }, { "name": "health", "parameters": "{$POD_IP}:8080" }, { "configBlock": "pods insecure\nfallthrough in-addr.arpa ip6.arpa", "name": "kubernetes", "parameters": "cluster.local in-addr.arpa ip6.arpa" }, { "name": "loadbalance", "parameters": "round_robin" }, { "name": "prometheus", "parameters": "{$POD_IP}:9153" }, { "configBlock": "policy random", "name": "forward", "parameters": ". /etc/resolv.conf" }, { "name": "reload" }, { "name": "log" } ], "port": 5353, "zones": [ { "zone": "." } ] } ], "stub_domains": { "acme.local": [ "1.2.3.4", "6.7.8.9" ] }, "upstream_nameservers": ["8.8.8.8", "8.8.4.4"] } |
plugin Name |
Description |
---|---|
bind |
Host IP address listened by coredns. You are advised to retain the default value {$POD_IP}. |
cache |
DNS cache is enabled. |
errors |
Errors are logged to stdout. |
health |
Health check configuration. The current listening IP address is {$POD_IP}:8080. Retain the default value. Otherwise, the coredns health check fails and coredns restarts repeatedly. |
kubernetes |
CoreDNS Kubernetes plug-in, which provides the service parsing capability in a cluster. |
loadbalance |
Round-robin DNS load balancer that randomizes the order of A, AAAA, and MX records in the answer. |
prometheus |
Port for obtaining coredns metrics. The default zone listening IP address is {$POD_IP}:9153. Retain the default value. Otherwise, CloudScope cannot collect coredns metrics. |
forward |
Any queries that are not within the cluster domain of Kubernetes will be forwarded to predefined resolvers (/etc/resolv.conf). |
reload |
The changed Corefile can be automatically reloaded. After editing the ConfigMap, wait for two minutes for the modification to take effect. |
DNS policies can be set on a per-pod basis. Currently, Kubernetes supports four types of DNS policies: Default, ClusterFirst, ClusterFirstWithHostNet, and None. For details, see https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/. 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: