kubernetes: service not resolved from inside pod from same namespace

51 Views Asked by At

Here my mongodb service:

NAME               TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)     AGE
espaidoc-mongodb   ClusterIP   10.43.152.2   <none>        27017/TCP   13d

I've created a pod where I'm trying to get access from:

~ kubectl exec -it localstack-6d5fcd975-ddrgv -c dind -- sh
/ # nslookup -debug espaidoc-mongodb.default.svc.cluster.local
Server:         127.0.0.1
Address:        127.0.0.1:53

Query #1 completed in 22ms:
** server can't find espaidoc-mongodb.default.svc.cluster.local: NXDOMAIN

Query #0 completed in 25ms:
** server can't find espaidoc-mongodb.default.svc.cluster.local: NXDOMAIN

/ # ping espaidoc-mongodb.default.svc.cluster.local
ping: bad address 'espaidoc-mongodb.default.svc.cluster.local'
/ #

I don't quite figure out why I'm not able to get access to my espaidoc-mongodb service from my localstack dind pod container...

Any ideas?

1

There are 1 best solutions below

2
ram p On BEST ANSWER

DinD uses the alpine image. The issue is in alpine image version 3.11.3 nslookup tool unable to resolve DNS

I tried with version 3.19.1 of dind it works fine. Make sure to use the latest version of DinD while using nslookup. But the connectivity between the pod using service endpoints works perfectly fine. It is only the issue of nslookup command. Even you can try to ping from same DinD image version you can see the packets are transmitted

# cat /etc/alpine-release
3.19.1

# nslookup demo-nginx-service.demo.svc.cluster.local
Server:         10.96.0.10
Address:        10.96.0.10:53

Name:   demo-nginx-service.demo.svc.cluster.local
Address: 10.96.4.243

# ping demo-nginx-service.demo.svc.cluster.local
  PING demo-nginx-service.demo.svc.cluster.local (10.96.4.243): 56 data bytes