docker-library / busybox

Docker Official Image packaging for Busybox
http://busybox.net
391 stars 126 forks source link

docker image busybox:latest nslookup not working in kubernetes #98

Closed chenjie199234 closed 3 years ago

chenjie199234 commented 3 years ago

docker image: busybox:latest

test busybox binary

nslookup www.baidu.com
not working
-----------------------------------------------------------------------------
nslookup xxx-service.xxx-namespace
not working

test golang's net.LookupHost

package main
import (
    "net"
)
func main(){
    addrs,e:=net.LookupHost("www.baidu.com")  
    if e!=nil{
        panic(e)
    }
    fmt.Println(addrs)
}
go run main.go
not working,this will panic
-----------------------------------------------------------------------------
change host to "xxx-service.xxx-namespace"
go run main.go
not working,this will panic

docker image: busybox:1.28

test busybox binary

nslookup www.baidu.com
working
~/app # nslookup www.baidu.com
Server:    172.21.0.10
Address 1: 172.21.0.10 kube-dns.kube-system.svc.cluster.local

Name:      www.baidu.com
Address 1: 180.101.49.11
Address 2: 180.101.49.12
------------------------------------------------------------------------------
nslookup xxx-service.xxx-namespace
working,but the output has some format problem
~/app # nslookup discovery-service.community
Server:    172.21.0.10
Address 1: 172.21.0.10 kube-dns.kube-system.svc.cluster.local

Name:      discovery-service.community
Address 1: 10.137.63.146 discovery-deployment-b75b8969b-7zzlz
Address 2: 10.137.63.184 10-137-63-184.discovery-service.community.svc.cluster.local
Address 3: 10.137.63.159 10-137-63-159.discovery-service.community.svc.cluster.local

test golang's net.LookupHost

package main
import (
    "net"
)
func main(){
    addrs,e:=net.LookupHost("www.baidu.com")  
    if e!=nil{
        panic(e)
    }
    fmt.Println(addrs)
}
go run main.go
working
output: [180.101.49.11,180.101.49.12]
-----------------------------------------------------------------------------
change host to "xxx-service.xxx-namespace"
go run main.go
working
output: [10.137.63.146,10.137.63.184,10.137.63.159]
wglambert commented 3 years ago

Duplicate of https://github.com/docker-library/busybox/issues/48

See https://bugs.busybox.net/show_bug.cgi?id=11161#c4 https://github.com/kubernetes/kubernetes/issues/66924#issuecomment-411804435 & https://github.com/kubernetes/kubernetes/issues/66924#issuecomment-411806846