Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab 7: nslookup (resolver) in busybox:latest fails to lookup service (mydb, myservice) #2

Open
ekc opened this issue Jul 7, 2020 · 1 comment

Comments

@ekc
Copy link

ekc commented Jul 7, 2020

initContainers of init-pod pod (lab7-1.yaml) may not run at all because it depends on the latest busybox image.
I found the behavior change is in busybox:1.29 to busybox:1.32 (latest) see Nslookup does not work in latest busybox image #48.

[root@master01 learn]# kubectl run --attach busybox --rm --image=busybox:latest --restart=Never -- \
> sh -c "sleep 4 && nslookup kubernetes"
If you don't see a command prompt, try pressing enter.
Server:         10.96.0.10
Address:        10.96.0.10:53

** server can't find kubernetes.default.svc.cluster.local: NXDOMAIN

*** Can't find kubernetes.svc.cluster.local: No answer
*** Can't find kubernetes.cluster.local: No answer
*** Can't find kubernetes.default.svc.cluster.local: No answer
*** Can't find kubernetes.svc.cluster.local: No answer
*** Can't find kubernetes.cluster.local: No answer

pod "busybox" deleted
pod default/busybox terminated (Error)

busybox:1.28 is working fine.

[root@master01 learn]# kubectl run --attach busybox --rm --image=busybox:1.28 --restart=Never -- \
> sh -c "sleep 4 && nslookup kubernetes"
If you don't see a command prompt, try pressing enter.
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local
pod "busybox" deleted
[root@master01 learn]#

So, a simple solution to solve this problem is to use busybox:1.28 as in this snippet.

[root@master01 learn]# cat lab7-1.yaml
apiVersion: v1
kind: Pod
metadata:
  name: init-pod
  labels:
    app: initapp
spec:
  containers:
  - name: main-container
    image: busybox
    command: ['sh', '-c', 'echo main app running && sleep 3600']
  initContainers:
  - name: init-myservice
    image: busybox:1.28
    command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done']
  - name: init-mydb
    image: busybox:1.28
    command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done']
[root@master01 learn]#

Another useful tool to troubleshoot DNS problem in kubernetes in dnsutils.

@Dichtrich
Copy link

Dichtrich commented Oct 7, 2023

thank you @ekc i almost go mad wondering why the Initpod wouldn't start.
@sandervanvugt you should probably pin the busybox version in your repo files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants