@@ -13,7 +13,7 @@ This page provides hints on diagnosing DNS problems.
13
13
{{% capture prerequisites %}}
14
14
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
15
15
* Kubernetes version 1.6 and above.
16
- * The cluster must be configured to use the ` kube-dns ` addon .
16
+ * The cluster must be configured to use the ` coredns ` (or ` kube-dns ` ) addons .
17
17
{{% /capture %}}
18
18
19
19
{{% capture steps %}}
@@ -68,7 +68,7 @@ nameserver 10.0.0.10
68
68
options ndots:5
69
69
```
70
70
71
- Errors such as the following indicate a problem with the kube-dns add-on or
71
+ Errors such as the following indicate a problem with the coredns/ kube-dns add-on or
72
72
associated Services:
73
73
74
74
```
@@ -93,6 +93,17 @@ nslookup: can't resolve 'kubernetes.default'
93
93
94
94
Use the ` kubectl get pods ` command to verify that the DNS pod is running.
95
95
96
+ For CoreDNS:
97
+ ``` shell
98
+ kubectl get pods --namespace=kube-system -l k8s-app=kube-dns
99
+ NAME READY STATUS RESTARTS AGE
100
+ ...
101
+ coredns-7b96bf9f76-5hsxb 1/1 Running 0 1h
102
+ coredns-7b96bf9f76-mvmmt 1/1 Running 0 1h
103
+ ...
104
+ ```
105
+
106
+ Or for kube-dns:
96
107
``` shell
97
108
kubectl get pods --namespace=kube-system -l k8s-app=kube-dns
98
109
NAME READY STATUS RESTARTS AGE
@@ -107,8 +118,26 @@ have to deploy it manually.
107
118
108
119
### Check for Errors in the DNS pod
109
120
110
- Use ` kubectl logs ` command to see logs for the DNS daemons .
121
+ Use ` kubectl logs ` command to see logs for the DNS containers .
111
122
123
+ For CoreDNS:
124
+ ``` shell
125
+ for p in $( kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o name) ; do kubectl logs --namespace=kube-system $p ; done
126
+ ```
127
+
128
+ Here is an example of a healthy CoreDNS log:
129
+
130
+ ```
131
+ .:53
132
+ 2018/08/15 14:37:17 [INFO] CoreDNS-1.2.2
133
+ 2018/08/15 14:37:17 [INFO] linux/amd64, go1.10.3, 2e322f6
134
+ CoreDNS-1.2.2
135
+ linux/amd64, go1.10.3, 2e322f6
136
+ 2018/08/15 14:37:17 [INFO] plugin/reload: Running configuration MD5 = 24e6c59e83ce706f07bcc82c31b1ea1c
137
+ ```
138
+
139
+
140
+ For kube-dns, there are 3 sets of logs:
112
141
``` shell
113
142
kubectl logs --namespace=kube-system $( kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o name | head -1) -c kubedns
114
143
@@ -117,8 +146,8 @@ kubectl logs --namespace=kube-system $(kubectl get pods --namespace=kube-system
117
146
kubectl logs --namespace=kube-system $( kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o name | head -1) -c sidecar
118
147
```
119
148
120
- See if there is any suspicious log. Letter '` W ` ', '` E ` ', '` F ` ' at the beginning
121
- represent Warning, Error and Failure. Please search for entries that have these
149
+ See if there are any suspicious error messages in the logs. In kube-dns, a '` W ` ', '` E ` ' or '` F ` ' at the beginning
150
+ of a line represents a Warning, Error or Failure. Please search for entries that have these
122
151
as the logging level and use
123
152
[ kubernetes issues] ( https://github.com/kubernetes/kubernetes/issues )
124
153
to report unexpected errors.
@@ -135,6 +164,8 @@ kube-dns ClusterIP 10.0.0.10 <none> 53/UDP,53/TCP 1h
135
164
...
136
165
```
137
166
167
+
168
+ Note that the service name will be "kube-dns" for both CoreDNS and kube-dns deployments.
138
169
If you have created the service or in the case it should be created by default
139
170
but it does not appear, see
140
171
[ debugging services] ( /docs/tasks/debug-application-cluster/debug-service/ ) for
@@ -158,20 +189,83 @@ For additional Kubernetes DNS examples, see the
158
189
[ cluster-dns examples] ( https://github.com/kubernetes/examples/tree/master/staging/cluster-dns )
159
190
in the Kubernetes GitHub repository.
160
191
192
+
193
+ ### Are DNS queries being received/processed?
194
+
195
+ You can verify if queries are being received by CoreDNS by adding the ` log ` plugin to the CoreDNS configuration (aka Corefile).
196
+ The CoreDNS Corefile is held in a ConfigMap named ` coredns ` . To edit it, use the command ...
197
+
198
+ ```
199
+ kubectl -n kube-system edit configmap coredns
200
+ ```
201
+
202
+ Then add ` log ` in the Corefile section per the example below.
203
+
204
+ ```
205
+ apiVersion: v1
206
+ kind: ConfigMap
207
+ metadata:
208
+ name: coredns
209
+ namespace: kube-system
210
+ data:
211
+ Corefile: |
212
+ .:53 {
213
+ log
214
+ errors
215
+ health
216
+ kubernetes cluster.local in-addr.arpa ip6.arpa {
217
+ pods insecure
218
+ upstream
219
+ fallthrough in-addr.arpa ip6.arpa
220
+ }
221
+ prometheus :9153
222
+ proxy . /etc/resolv.conf
223
+ cache 30
224
+ loop
225
+ reload
226
+ loadbalance
227
+ }
228
+
229
+ ```
230
+
231
+ After saving the changes, it may take up to minute or two for Kubernetes to propagate these changes to the CoreDNS pods.
232
+
233
+ Next, make some queries and view the logs per the sections above in this document. If CoreDNS pods are receiving the queries, you should see them in the logs.
234
+
235
+ Here is an example of a query in the log.
236
+
237
+ ```
238
+ .:53
239
+ 2018/08/15 14:37:15 [INFO] CoreDNS-1.2.0
240
+ 2018/08/15 14:37:15 [INFO] linux/amd64, go1.10.3, 2e322f6
241
+ CoreDNS-1.2.0
242
+ linux/amd64, go1.10.3, 2e322f6
243
+ 2018/09/07 15:29:04 [INFO] plugin/reload: Running configuration MD5 = 162475cdf272d8aa601e6fe67a6ad42f
244
+ 2018/09/07 15:29:04 [INFO] Reloading complete
245
+ 172.17.0.18:41675 - [07/Sep/2018:15:29:11 +0000] 59925 "A IN kubernetes.default.svc.cluster.local. udp 54 false 512" NOERROR qr,aa,rd,ra 106 0.000066649s
246
+
247
+ ```
248
+
161
249
## Known issues
162
250
163
- Kubernetes installs do not configure the nodes' resolv.conf files to use the
164
- cluster DNS by default, because that process is inherently distro-specific.
251
+ Some Linux distributions (e.g. Ubuntu), use a local DNS resolver by default (systemd-resolved).
252
+ Systemd-resolved moves and replaces ` /etc/resolv.conf ` with a stub file that can cause a fatal forwarding
253
+ loop when resolving names in upstream servers. This can be fixed manually by using kubelet's ` --resolv-conf ` flag
254
+ to point to the correct ` resolv.conf ` (With ` systemd-resolved ` , this is ` /run/systemd/resolve/resolv.conf ` ).
255
+ kubeadm 1.11 automatically detects ` systemd-resolved ` , and adjusts the kubelet flags accordingly.
256
+
257
+ Kubernetes installs do not configure the nodes' ` resolv.conf ` files to use the
258
+ cluster DNS by default, because that process is inherently distribution-specific.
165
259
This should probably be implemented eventually.
166
260
167
261
Linux's libc is impossibly stuck ([ see this bug from
168
262
2005] ( https://bugzilla.redhat.com/show_bug.cgi?id=168253 ) ) with limits of just
169
- 3 DNS ` nameserver ` records and 6 DNS ` search ` records. Kubernetes needs to
170
- consume 1 ` nameserver ` record and 3 ` search ` records. This means that if a
263
+ 3 DNS ` nameserver ` records and 6 DNS ` search ` records. Kubernetes needs to
264
+ consume 1 ` nameserver ` record and 3 ` search ` records. This means that if a
171
265
local installation already uses 3 ` nameserver ` s or uses more than 3 ` search ` es,
172
- some of those settings will be lost. As a partial workaround, the node can run
266
+ some of those settings will be lost. As a partial workaround, the node can run
173
267
` dnsmasq ` which will provide more ` nameserver ` entries, but not more ` search `
174
- entries. You can also use kubelet's ` --resolv-conf ` flag.
268
+ entries. You can also use kubelet's ` --resolv-conf ` flag.
175
269
176
270
If you are using Alpine version 3.3 or earlier as your base image, DNS may not
177
271
work properly owing to a known issue with Alpine.
0 commit comments