jack
jack

Reputation: 1538

Kubernetes pods unable to resolve host :

I have setup an Azure Kubernetes Cluster using kubenet plugin. All pods and services are running. Also, when I do a kubectl get pods -n kube-system all pods are running.

The issue I have is, the pods are unable to connect to other pods via hostnames. However, if I use the pod ip addresses : portname, they are able to connect.

When I am logged into a pod and do a curl ex: pod-x$ curl http://my-pod-y:2000/analysis

I get the error:

could not resolve host http://my-pod-y

But when I delete all the coredns pods with kube-system namespaces, and retry the curl commands within the pod, they are able to access the other pods using hostnames!

But when I try after 10 mins it gives the could not resolve host error.

Any pointers on this will be much appreciated.

Upvotes: 5

Views: 2923

Answers (1)

Philip Welz
Philip Welz

Reputation: 2817

Kuberentes uses different DNS schemes for PODs.

The DNS schema for a Pod in the default NS with IP 172.17.0.3 is :

172-17-0-3.default.pod.cluster.local
pod-ip-address.namespace.pod.cluster-domain.example

If you want to use DNS name, you have to uses services. For a Service test in the default NS the DNS record is:

test.default.svc.cluster.local
svc.namespace.svc.cluster-domain.example

You can check this here: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

Upvotes: 0

Related Questions