When I run nslookup
on my docker container, I get this error
nslookup 10.0.96.xx
nslookup: can't resolve '(null)': Name does not resolve
Name: 10.0.96.xx
Address 1: 10.0.96.xx
I've read that the problem comes from docker which injects this on the resolv.conf
:
nameserver 10.109.0.xx
nameserver 10.96.0.xx
search devlan.xxx.corp poc.svc.cluster.local svc.cluster.local cluster.local
options ndots:2 edns0
With kubernetes, I tried to overwrite it with the following parameters on my PodConfFile.yaml
.
spec:
dnsPolicy: "None"
# dnsPolicy: ClusterFirst
dnsConfig:
nameservers:
- 10.109.0.xx
- 10.96.0.xx
searches:
- devlan.xxx.corp
- poc.svc.cluster.local
- svc.cluster.local
- cluster.local
options:
- name: ndots
value: "2"
- name: edns0
Do you have any advice to resolve this issue?
otherwise i found another solution much cleaner
whether your pod can't resolve a URL and you have @IP 10.0.96.XX in your /etc/resolv.conf
nslookup 10.0.96.xx
nslookup: can't resolve '(null)': Name does not resolve
To fix it :
vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
change @IP address with your IP
Environment="KUBELET_DNS_ARGS=--cluster-dns=YOUR-IP-DNS --cluster-domain=cluster.local"
And restart kublet
systemctl restart kubelet.service
I hope this will help you ;)
And you can remove from Pod.yaml
DnsPolicy
i found a solution to this issue . on your Pod remove this params
nameserver options searches
and add thie one
spec:
dnsPolicy: Default
it will inherit directly the DNS configuration .
you will be able to ping a external services .