Internal cluster DNS resolution¶
In Kubernetes, services are assigned a DNS name that other resources within the cluster can use to discover and communicate with them. This resolution is handled by a cluster-aware DNS server and is accessible from within Pods.^[400-devops-06-kubernetes-k8s-learning-05service-service.md]
DNS Records and Formats¶
Kubernetes generates DNS records for Services (and Pods) following specific conventions.^[400-devops-06-kubernetes-k8s-learning-05service-service.md] The standard format for a DNS record includes the service name, the namespace name, and the svc suffix, structured as <service-name>.<namespace>.svc.^[400-devops-06-kubernetes-k8s-learning-05service-service.md]
For example, a service named nginx-deployment-service in the default namespace can be addressed via FQDN as nginx-deployment-service.default.svc.^[400-devops-06-kubernetes-k8s-learning-05service-service.md]
Resolution Shortforms¶
While the fully qualified domain name (FQDN) is available, shorter forms are often supported for convenience within the same namespace context.^[400-devops-06-kubernetes-k8s-learning-05service-service.md]
- Service Name Only: Applications can reach a service using only its name (e.g.,
nginx-deployment-service).^[400-devops-06-kubernetes-k8s-learning-05service-service.md] - Namespace Qualifier: A service can be accessed using the
<service-name>.<namespace>format (e.g.,nginx-deployment-service.default), bypassing the need for the full domain suffix.^[400-devops-06-kubernetes-k8s-learning-05service-service.md]
Access patterns from Pods¶
Internal DNS resolution allows running applications to connect to services abstractly without knowing the underlying cluster IP.^[400-devops-06-kubernetes-k8s-learning-05service-service.md] Inside a Pod, tools like curl can request these services using the DNS name, which then resolves to the service's Cluster IP.^[400-devops-06-kubernetes-k8s-learning-05service-service.md]
The system also facilitates access across different namespaces. While a Pod in the same namespace can use the short service name, the FQDN or namespace-qualified name allows Pods in one namespace to reliably reach Services in another.^[400-devops-06-kubernetes-k8s-learning-05service-service.md]
Sources¶
^[400-devops-06-kubernetes-k8s-learning-05service-service.md]