Skip to content

Commit 3091bbe

Browse files
committed
Fixes #6: An oddysee: All resolves to a known Ubuntu bug :( Now a new role resolves that problem and kube-dns picks up the correct DNS nameserver from /etc/resolve.conf.
1 parent dc5e77c commit 3091bbe

File tree

6 files changed

+53
-3
lines changed

6 files changed

+53
-3
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,16 @@ See the following links:
137137

138138
##### Kubernetes DNS (kube-dns)
139139

140+
Debug Service DNS: https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/#does-the-service-work-by-ip
141+
142+
Debug kube-dns: https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/
143+
140144
https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/:
141145

142146
> Kubernetes DNS schedules a DNS Pod and Service on the cluster, and configures the kubelets to tell individual containers to use the DNS Service’s IP to resolve DNS names.
143147
144-
####### nslookup for kubernetes not working in kubedns / main.yml
148+
149+
###### nslookup for kubernetes not working in kubedns / main.yml
145150

146151
We set `--ip-masq=false` inside the `docker.service`. The problem is
147152

@@ -167,6 +172,36 @@ Name: kubernetes
167172
Address 1: 10.32.0.1 kubernetes.default.svc.cluster.local
168173
```
169174

175+
###### if nslookup still doesnt work - "If the outer resolv.conf points to 127.0.0.1:53, then you will have a DNS lookup loop"
176+
177+
see https://github.com/kubernetes/kubernetes/issues/49411#issuecomment-318096636
178+
179+
> Kubedns inherits the contents of “/etc/resolv.conf” something the maintainers of these pods should document at the following site (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/dns ) as it takes a lot of research and googling to find such details hidden under forum comments. My two cents
180+
181+
check your Ubuntu boxes `cat /etc/resolve.conf`:
182+
183+
```
184+
nameserver 127.0.0.53
185+
```
186+
187+
> systemd-resolved on my host listens on 127.0.0.53:53 for dns queries, as soon as I uninstall systemd-resolved and install dnsmasq my node has an entry of 127.0.0.1 in /etc/resolv.conf instead of 127.0.0.53, this gets inherited by the kubedns pods and for some reason its able to forward unresolved queries to my host dnsmasq. Earlier, the kubedns inherited the 127.0.0.53 IP from node “/etc/resolv.conf” and for some reason its not able to talk to the node systemd-resolved at that IP.
188+
189+
190+
__Solution:__
191+
192+
See https://askubuntu.com/a/974482/451114 & https://askubuntu.com/questions/952284/dns-system-is-failing-to-resolve-domain-names-occasionally#comment1589832_952284
193+
194+
```
195+
sudo mv /etc/resolv.conf /etc/resolv.conf_orig
196+
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
197+
```
198+
199+
Now `cat /etc/resolve.conf` should inherit the correct nameserver (VirtualBox DNS server):
200+
201+
```
202+
nameserver 10.0.2.3
203+
```
204+
170205
### Where did we stop? (on 22. Juni 2018)
171206

172207
We´ve reached every step till:
@@ -206,6 +241,7 @@ curl --cacert certificates/ca.pem --key certificates/admin-key.pem --cert certif
206241
* [kubernetes by example][4]
207242
* [Best practice by google][5]
208243
* [Tutorialspoint][6]
244+
* Tutorials: https://kubernetes.io/docs/tutorials/kubernetes-basics/explore/explore-intro/
209245

210246

211247
[0]: https://kubernetes.io/docs/reference/kubectl/cheatsheet/

k8s-external-access.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
- hosts: master-0
22
become: yes
33
roles:
4-
- { role: kubedns, tags: kubedns }
54
- { role: dashboard, tags: dashboard }
65

76
- hosts: external

k8s-worker-nodes.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
- hosts: worker
22
become: yes
33
roles:
4+
- { role: fix-ubuntu-dns, tags: fixubuntu }
45
- { role: k8s-worker, tags: k8s-worker }
56

67
- hosts: master-0
78
become: yes
89
roles:
910
- { role: verify-worker, tags: verify }
11+
- { role: kubedns, tags: kubedns }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# see https://stackoverflow.com/a/52036125/4964553
2+
# this is needed later for a working kube-dns DNS resolution
3+
- name: Remove original /etc/resolv.conf
4+
shell: mv /etc/resolv.conf /etc/resolv.conf_orig
5+
6+
- name: Link /run/systemd/resolve/resolv.conf as new /etc/resolv.conf
7+
file:
8+
src: /run/systemd/resolve/resolv.conf
9+
dest: /etc/resolv.conf
10+
state: link
11+

roles/k8s-master/templates/kube-controller-manager.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ExecStart=/usr/local/bin/kube-controller-manager \
77
--address=0.0.0.0 \
88
--cluster-cidr={{ kubernetes_cluster_cidr }} \
99
--allocate-node-cidrs=true \
10-
--cluster-name=kubernetes \
10+
--cluster-name=kubernetes-the-ansible-way \
1111
--cluster-signing-cert-file=/var/lib/kubernetes/ca.pem \
1212
--cluster-signing-key-file=/var/lib/kubernetes/ca-key.pem \
1313
--kubeconfig=/var/lib/kubernetes/kube-controller-manager.kubeconfig \

roles/kubedns/templates/kube-dns.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ spec:
163163
- --server=/cluster.local/127.0.0.1#10053
164164
- --server=/in-addr.arpa/127.0.0.1#10053
165165
- --server=/ip6.arpa/127.0.0.1#10053
166+
# see https://github.com/eBayClassifiedsGroup/PanteraS/issues/166#issuecomment-169779226
167+
- --dns-forward-max=300
166168
ports:
167169
- containerPort: 53
168170
name: dns

0 commit comments

Comments
 (0)