You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Using NodeLocal DNSCache in Kubernetes clusters
14
10
content_type: task
15
-
---
16
11
-->
17
12
18
13
<!-- overview -->
@@ -22,14 +17,10 @@ This page provides an overview of NodeLocal DNSCache feature in Kubernetes.
22
17
-->
23
18
本页概述了 Kubernetes 中的 NodeLocal DNSCache 功能。
24
19
25
-
26
-
27
20
## {{% heading "prerequisites" %}}
28
21
29
-
30
22
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
31
23
32
-
33
24
<!-- steps -->
34
25
35
26
<!--
@@ -40,11 +31,11 @@ This page provides an overview of NodeLocal DNSCache feature in Kubernetes.
40
31
<!--
41
32
NodeLocal DNSCache improves Cluster DNS performance by running a dns caching agent on cluster nodes as a DaemonSet. In today's architecture, Pods in ClusterFirst DNS mode reach out to a kube-dns serviceIP for DNS queries. This is translated to a kube-dns/CoreDNS endpoint via iptables rules added by kube-proxy. With this new architecture, Pods will reach out to the dns caching agent running on the same node, thereby avoiding iptables DNAT rules and connection tracking. The local caching agent will query kube-dns service for cache misses of cluster hostnames(cluster.local suffix by default).
42
33
-->
43
-
NodeLocal DNSCache 通过在集群节点上作为 DaemonSet 运行 dns 缓存代理来提高集群 DNS 性能。
44
-
在当今的体系结构中,处于 ClusterFirst DNS 模式的 Pod 可以连接到 kube-dns serviceIP 进行 DNS 查询。
34
+
NodeLocal DNSCache 通过在集群节点上作为 DaemonSet 运行 DNS 缓存代理来提高集群 DNS 性能。
35
+
在当今的体系结构中,运行在 ClusterFirst DNS 模式下的 Pod 可以连接到 kube-dns `serviceIP` 进行 DNS 查询。
* With the current DNS architecture, it is possible that Pods with the highest DNS QPS have to reach out to a different node, if there is no local kube-dns/CoreDNS instance.
56
47
Having a local cache will help improve the latency in such scenarios.
57
48
-->
58
-
* 使用当前的 DNS 体系结构,如果没有本地 kube-dns/CoreDNS 实例,则具有最高 DNS QPS 的 Pod 可能必须延伸到另一个节点。
59
-
在这种脚本下,拥有本地缓存将有助于改善延迟。
49
+
* 使用当前的 DNS 体系结构,如果没有本地 kube-dns/CoreDNS 实例,则具有最高 DNS QPS
50
+
的 Pod 可能必须延伸到另一个节点。
51
+
在这种场景下,拥有本地缓存将有助于改善延迟。
60
52
61
53
<!--
62
54
* Skipping iptables DNAT and connection tracking will help reduce [conntrack races](https://github.com/kubernetes/kubernetes/issues/56903) and avoid UDP DNS entries filling up conntrack table.
* Connections from local caching agent to kube-dns servie can be upgraded to TCP. TCP conntrack entries will be removed on connection close in contrast with UDP entries that have to timeout ([default](https://www.kernel.org/doc/Documentation/networking/nf_conntrack-sysctl.txt) `nf_conntrack_udp_timeout` is 30 seconds)
* Upgrading DNS queries from UDP to TCP would reduce tail latency attributed to dropped UDP packets and DNS timeouts usually up to 30s (3 retries + 10s timeout). Since the nodelocal cache listens for UDP DNS queries, applications don't need to be changed.
74
70
-->
75
-
* 将 DNS 查询从 UDP 升级到 TCP 将减少归因于丢弃的 UDP 数据包和 DNS 超时的尾部等待时间,通常长达 30 秒(3 次重试+ 10 秒超时)。
71
+
* 将 DNS 查询从 UDP 升级到 TCP 将减少由于被丢弃的 UDP 包和 DNS 超时而带来的尾部等待时间;
72
+
这类延时通常长达 30 秒(3 次重试 + 10 秒超时)。
73
+
由于 nodelocal 缓存监听 UDP DNS 查询,应用不需要变更。
76
74
77
75
<!--
78
76
* Metrics & visibility into dns requests at a node level.
79
77
-->
80
-
* 在节点级别对 dns 请求的度量和可见性。
78
+
* 在节点级别对 DNS 请求的度量和可见性。
81
79
82
80
<!--
83
81
* Negative caching can be re-enabled, thereby reducing number of queries to kube-dns service.
@@ -129,7 +126,8 @@ This feature can be enabled using the following steps:
129
126
If you are using the sample manifest from the previous point, this will require to modify [the configuration line L70](https://github.com/kubernetes/kubernetes/blob/b2ecd1b3a3192fbbe2b9e348e095326f51dc43dd/cluster/addons/dns/nodelocaldns/nodelocaldns.yaml#L70) like this `health [__PILLAR__LOCAL__DNS__]:8080`
@@ -161,16 +161,16 @@ If you are using the sample manifest from the previous point, this will require
161
161
`__PILLAR__CLUSTER__DNS__` and `__PILLAR__UPSTREAM__SERVERS__` will be populated by the node-local-dns pods.
162
162
In this mode, node-local-dns pods listen on both the kube-dns service IP as well as `<node-local-address>`, so pods can lookup DNS records using either IP address.
163
163
-->
164
-
* 如果 kube-proxy 运行在 IPTABLES 模式:
164
+
* 如果 kube-proxy 运行在 IPTABLES 模式:
165
165
166
-
```bash
167
-
sed -i "s/__PILLAR__LOCAL__DNS__/$localdns/g; s/__PILLAR__DNS__DOMAIN__/$domain/g; s/__PILLAR__DNS__SERVER__/$kubedns/g" nodelocaldns.yaml
168
-
```
166
+
```bash
167
+
sed -i "s/__PILLAR__LOCAL__DNS__/$localdns/g; s/__PILLAR__DNS__DOMAIN__/$domain/g; s/__PILLAR__DNS__SERVER__/$kubedns/g" nodelocaldns.yaml
在此模式下, node-local-dns Pods 会同时侦听 kube-dns 服务的 IP 地址和
172
+
`<node-local-address>` 的地址,以便 Pods 可以使用其中任何一个 IP 地址来查询 DNS 记录。
173
+
<!--
174
174
* If kube-proxy is running in IPVS mode:
175
175
176
176
``` bash
@@ -179,32 +179,121 @@ If you are using the sample manifest from the previous point, this will require
179
179
In this mode, node-local-dns pods listen only on `<node-local-address>`. The node-local-dns interface cannot bind the kube-dns cluster IP since the interface used for IPVS loadbalancing already uses this address.
180
180
`__PILLAR__UPSTREAM__SERVERS__` will be populated by the node-local-dns pods.
181
181
-->
182
-
* 如果 kube-proxy 运行在 IPVS 模式:
182
+
* 如果 kube-proxy 运行在 IPVS 模式:
183
183
184
-
``` bash
185
-
sed -i "s/__PILLAR__LOCAL__DNS__/$localdns/g; s/__PILLAR__DNS__DOMAIN__/$domain/g; s/__PILLAR__DNS__SERVER__//g; s/__PILLAR__CLUSTER__DNS__/$kubedns/g" nodelocaldns.yaml
186
-
```
184
+
``` bash
185
+
sed -i "s/__PILLAR__LOCAL__DNS__/$localdns/g; s/__PILLAR__DNS__DOMAIN__/$domain/g; s/__PILLAR__DNS__SERVER__//g; s/__PILLAR__CLUSTER__DNS__/$kubedns/g" nodelocaldns.yaml
* If using kube-proxy in IPVS mode, `--cluster-dns` flag to kubelet needs to be modified to use `<node-local-address>` that NodeLocal DNSCache is listening on.
196
196
Otherwise, there is no need to modify the value of the `--cluster-dns` flag, since NodeLocal DNSCache listens on both the kube-dns service IP as well as `<node-local-address>`.
Once enabled, node-local-dns Pods will run in the kube-system namespace on each of the cluster nodes. This Pod runs [CoreDNS](https://github.com/coredns/coredns) in cache mode, so all CoreDNS metrics exposed by the different plugins will be available on a per-node basis.
204
206
205
207
You can disable this feature by removing the DaemonSet, using `kubectl delete -f <manifest>`. You should also revert any changes you made to the kubelet configuration.
node-local-dns pods use memory for storing cache entries and processing queries. Since they do not watch Kubernetes objects, the cluster size or the number of Services/Endpoints do not directly affect memory usage. Memory usage is influenced by the DNS query pattern.
244
+
From [CoreDNS docs](https://github.com/coredns/deployment/blob/master/kubernetes/Scaling_CoreDNS.md),
245
+
> The default cache size is 10000 entries, which uses about 30 MB when completely filled.
0 commit comments