DNS within Cluster

Hi I have created a deployment for 2 pods within a worker node and both of them have started successfully.

Pod A’s IP Address: 10.42.21.54
Pod B’s IP Address: 10.42.21.55

I would like to have Pod B communicating with Pod A but since the IP assigned to Pod A (10.42.21.54) is not static, I can only do so via a hostname and letting a DNS resolve it.

Based on this article, the DNS record is created automatically and I should be able to access Pod A via 10-42-21-54.default.pod.cluster.local. However, this did not work when I tried pinging from Pod B’s shell. Also this approach would still require me to know Pod A’s IP beforehand.

I have tried to create a hostname in Pod A’s deployment and pinging it from Pod B (pod-a-hostname.default.pod.cluster.local) but it did not work as well. I suspect that my pods have some issues related to the DNS and hence was unable to reach any other pods within the same cluster. How can I go about fixing this issue?

To add on, checking the /etc/resolv.conf file within Pod B shows the following

/data # cat /etc/resolv.conf
search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.43.0.10
options ndots:5

However, when I tried to ping 10.43.0.10, I am unable to get any response.