kube_pod_labels does populates pod_label_node_name and pod_label_host_ip for the given pod however the values don't correspond to the actual node name and ip of the pod.
Instead it represents the node name and ip for kube-state-metrics/node-exporter node.
As a result these values are to be same for all the pods.
What is the right way to get the actual node name and ip of the Pod in Prometheus?
It looks like you have improper configuration for scraping
kube-state-metricstarget. This target must be scraped spearately from other pods, and it shouldn't have relabeling rules, which setnode,pod,containerandnamespacelabels, since these labels are already set to proper values bykube-state-metricsitself - see these docs.kube-state-metricsalso sets labels based on pod annotations and pod labels, so these labels also shoudn't be set by relabeling config forkube-state-metricstarget.When
kube-state-metricsis scraped correctly, then the hostname of every pod can be obtained vianodeandhost_iplabel atkube_pod_infometric - see these docs.