Hi @Tej_Singh_Rana, @Vijin Palazhi, Team, Can nslookup (to some web site <http: . . .

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?

Tej_Singh_Rana:
Hello, @Mudit
If you want everything then create your own image from Dockerfile.

Mudit:
Thank you @Tej_Singh_Rana for your response. Side question:
Does the below DNS IP come automatically in /etc/resolv.conf when kubernetes cluster is configured using Vagrant files from KodeKloud? If yes, then if we replace it with some other generic DNS (like 8.8.8.8), hope it should not impact any functionality? (I think it should not have any dependency on this particular DNS only)

root@nginx-6bb6bb857b-hn4kc:/# cat /etc/resolv.conf
nameserver 10.96.0.10

Tej_Singh_Rana:
Hello, @Mudit
We have just set the virtual machines from the vagrantfile, to install k8s cluster. Vagrantfile is only for provision virtual machine.

Mudit:
Hello @Tej_Singh_Rana,
Oops, yeah I got it wrong. So this DNS IP in the PODs (on this K8s cluster) is getting configured from where? I see same IP in both busybox POD and Nginx POD. And this IP gets me connection error. Thinking, how can it be changed to a working DNS IP (apart from manually editing the resolv.conf inside POD - for nginx POD, it does not allow any edit till I customize it via a Dockerfile)

Tej_Singh_Rana:
Please have a look into this k8s docs.
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/kubelet-integration/#propagating-cluster-level-configuration-to-each-kubelet|https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/kubelet-integration/#propagating-cluster-level-c[…]nfiguration-to-each-kubelet
It picks the default value.