docker-library / busybox

Docker Official Image packaging for Busybox

Home Page:http://busybox.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker image busybox:latest nslookup not working in kubernetes

chenjie199234 opened this issue · comments

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]