Usually CoreDNS is used for cluster DNS
DNS record (A) for a service:<service>.<namespace>.svc.cluster.local
DNS record (A) for a pod with IP 1.2.3.4
:<1-2-3-4>.<namespace>.pod.cluster.local
Add DNS server for custom domains
Services hide infrastructure
ClusterIP
Service implements a load balancer
DNS record for service name is created
NodePort
Services exposes ports on node
Default port range is 30000-32767
LoadBalancer
Service integrated with cloud provider’s load balancer
Services hide infrastructure
ExternalName
Maps cluster IP and DNS record to well-known name
For example, central database server
ClusterIP=None
(headless service)No cluster IP
No load balancing
DNS A records for all matched pods
Understand how they work
Type | IP | LB | DNS |
---|---|---|---|
ClusterIP | Yes | No | Resolves to cluster IP |
None | No | Yes | Resolves to all pod IPs |