Discussing the DNS Operator and DNS Records for Services
The DNS operator deploys and runs a DNS server managed by CoreDNS, a lightweight DNS server written in GoLang. The DNS operator provides DNS name resolution between pods, which enables services to discover their endpoints.
Every time you create a new application, OKD configures the pods so that they contact the CoreDNS service IP for DNS resolution.
Run the following command to review the configuration of the DNS operator.
oc describe dns.operator/default
The DNS operator is responsible for the following:
- Creating a default cluster DNS name (cluster.local).
- Assigning a DNS name to a namespace (for example, backend.cluster.local).
- Assigning DNS names to services that you define (for example, db.backend.cluster.local).
- Assigning DNS names to pods in a namespace (such as db001.backend.cluster.local).
DNS Records for Services
This DNS implementation allows pods to seamlessly resolve DNS names for resources in a project or the cluster. Pods can use a predictable naming scheme for accessing a service. For example, querying the db.backend.cluster.local from a container returns the IP address of the service. In this case, db is the name of the service, backend is the project name, and cluster.local is the cluster DNS name.
CoreDNS creates two kind of records for services: A records that resolve to services, and SRV records that match the following format:
For example, if you use a service that exposes the TCP port 443 through the HTTPS service, the SRV record is created as follows: