Mudit:
Hi @Tej_Singh_Rana, @Vijin Palazhi, Team,
Can nslookup (to some web site http://www.example.com|www.example.com) work from inside the “nginx” pod (created using nginx image) somehow? It works for busybox:1.28, but not for nginx.
Any inputs? It would really be helpful.
Error while trying nslookup from nginx pod, because ‘nslookup’ command is not found:
root@kubemaster:/etc/kubernetes# kubectl exec --stdin --tty nginx-6bb6bb857b-hn4kc -- nslookup <http://www.google.com|www.google.com>
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"nslookup\": executable file not found in $PATH": unknown
command terminated with exit code 126
root@kubemaster:/etc/kubernetes#
root@kubemaster:/etc/kubernetes# kubectl exec -it nginx-6bb6bb857b-hn4kc -- /bin/bash
root@nginx-6bb6bb857b-hn4kc:/# nslookup
bash: nslookup: command not found
apt-get update error. DNS not working it seems:
root@nginx-6bb6bb857b-hn4kc:/# apt-get update
Err:1 <http://deb.debian.org/debian> buster InRelease
Temporary failure resolving '<http://deb.debian.org|deb.debian.org>'
Err:2 <http://security.debian.org/debian-security> buster/updates InRelease
Temporary failure resolving '<http://security.debian.org|security.debian.org>'
Err:3 <http://deb.debian.org/debian> buster-updates InRelease
Temporary failure resolving '<http://deb.debian.org|deb.debian.org>'
Reading package lists... Done
W: Failed to fetch <http://deb.debian.org/debian/dists/buster/InRelease> Temporary failure resolving '<http://deb.debian.org|deb.debian.org>'
W: Failed to fetch <http://security.debian.org/debian-security/dists/buster/updates/InRelease> Temporary failure resolving '<http://security.debian.org|security.debian.org>'
W: Failed to fetch <http://deb.debian.org/debian/dists/buster-updates/InRelease> Temporary failure resolving '<http://deb.debian.org|deb.debian.org>'
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@nginx-6bb6bb857b-hn4kc:/#
The below DNS IP came automatically in /etc/resolv.conf when kubernetes cluster was configured using Vagrant files from KodeKloud:
root@nginx-6bb6bb857b-hn4kc:/# cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
root@nginx-6bb6bb857b-hn4kc:/#
“vi” or “vim” commands are not found on this nginx pod with Ubuntu as base. I thought to add a working DNS “8.8.8.8” so as to get the installations of these commands done via apt-get.
root@nginx-6bb6bb857b-hn4kc:/# vi /etc/resolv.conf
bash: vi: command not found
root@nginx-6bb6bb857b-hn4kc:/# uname -a
Linux nginx-6bb6bb857b-hn4kc 4.15.0-124-generic #127-Ubuntu SMP Fri Nov 6 10:54:43 UTC 2020 x86_64 GNU/Linux
‘sed’ command is present. I thought to insert 8.8.8.8 (working DNS IP) via sed command in /etc/resolv.conf. Althought commands runs, but it does not work, meaning the data is not getting inserted:
root@nginx-6bb6bb857b-hn4kc:/# sed '2 i nameserver 8.8.8.8' /etc/resolv.conf
nameserver 10.96.0.10
nameserver 8.8.8.8
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
root@nginx-6bb6bb857b-hn4kc:/#
root@nginx-6bb6bb857b-hn4kc:/# cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
root@nginx-6bb6bb857b-hn4kc:/#
Do we need to create this nginx pod itself differently, so that eventually I am able to reach a generic sites (like http://www.google.com|www.google.com) from inside the POD?