@@ -7,8 +7,8 @@ content_type: concept
7
7
weight : 20
8
8
---
9
9
<!-- overview -->
10
- This page provides an overview of DNS support by Kubernetes.
11
-
10
+ Kubernetes creates DNS records for services and pods. You can contact
11
+ services with consistent DNS names instead of IP addresses.
12
12
13
13
<!-- body -->
14
14
@@ -18,19 +18,47 @@ Kubernetes DNS schedules a DNS Pod and Service on the cluster, and configures
18
18
the kubelets to tell individual containers to use the DNS Service's IP to
19
19
resolve DNS names.
20
20
21
- ### What things get DNS names?
22
-
23
21
Every Service defined in the cluster (including the DNS server itself) is
24
- assigned a DNS name. By default, a client Pod's DNS search list will
25
- include the Pod's own namespace and the cluster's default domain. This is best
26
- illustrated by example:
22
+ assigned a DNS name. By default, a client Pod's DNS search list includes the
23
+ Pod's own namespace and the cluster's default domain.
24
+
25
+ ### Namespaces of Services
26
+
27
+ A DNS query may return different results based on the namespace of the pod making
28
+ it. DNS queries that don't specify a namespace are limited to the pod's
29
+ namespace. Access services in other namespaces by specifying it in the DNS query.
30
+
31
+ For example, consider a pod in a ` test ` namespace. A ` data ` service is in
32
+ the ` prod ` namespace.
33
+
34
+ A query for ` data ` returns no results, because it uses the pod's ` test ` namespace.
35
+
36
+ A query for ` data.prod ` returns the intended result, because it specifies the
37
+ namespace.
38
+
39
+ DNS queries may be expanded using the pod's ` /etc/resolv.conf ` . Kubelet
40
+ sets this file for each pod. For example, a query for just ` data ` may be
41
+ expanded to ` data.test.cluster.local ` . The values of the ` search ` option
42
+ are used to expand queries. To learn more about DNS queries, see
43
+ [ the ` resolv.conf ` manual page.] ( https://www.man7.org/linux/man-pages/man5/resolv.conf.5.html )
44
+
45
+ ```
46
+ nameserver 10.32.0.10
47
+ search <namespace>.svc.cluster.local svc.cluster.local cluster.local
48
+ options ndots:5
49
+ ```
50
+
51
+ In summary, a pod in the _ test_ namespace can successfully resolve either
52
+ ` data.prod ` or ` data.prod.cluster.local ` .
53
+
54
+ ### DNS Records
55
+
56
+ What objects get DNS records?
27
57
28
- Assume a Service named ` foo ` in the Kubernetes namespace ` bar ` . A Pod running
29
- in namespace ` bar ` can look up this service by querying a DNS service for
30
- ` foo ` . A Pod running in namespace ` quux ` can look up this service by doing a
31
- DNS query for ` foo.bar ` .
58
+ 1 . Services
59
+ 2 . Pods
32
60
33
- The following sections detail the supported record types and layout that is
61
+ The following sections detail the supported DNS record types and layout that is
34
62
supported. Any other layout or names or queries that happen to work are
35
63
considered implementation details and are subject to change without warning.
36
64
For more up-to-date specification, see
0 commit comments