简体   繁体   English

Kubernetes pod 无法解析主机:

[英]Kubernetes pods unable to resolve host :

I have setup an Azure Kubernetes Cluster using kubenet plugin.我已经使用 kubenet 插件设置了一个 Azure Kubernetes 集群。 All pods and services are running.所有 pod 和服务都在运行。 Also, when I do a kubectl get pods -n kube-system all pods are running.此外,当我执行kubectl get pods -n kube-system时,所有 pod 都在运行。

The issue I have is, the pods are unable to connect to other pods via hostnames.我遇到的问题是,这些 pod 无法通过主机名连接到其他 pod。 However, if I use the pod ip addresses: portname, they are able to connect.但是,如果我使用 pod ip 地址:端口名,它们可以连接。

When I am logged into a pod and do a curl ex: pod-x$ curl http://my-pod-y:2000/analysis当我登录到 pod 并执行 curl 例如: pod-x$ curl http://my-pod-y:2000/analysis

I get the error:我得到错误:

could not resolve host http://my-pod-y无法解析主机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!但是,当我删除所有具有 kube-system 命名空间的 coredns pod,并在 pod 中重试 curl 命令时,他们能够使用主机名访问其他 pod!

But when I try after 10 mins it gives the could not resolve host error.但是当我在 10 分钟后尝试时,它给出了无法解决主机错误。

Any pointers on this will be much appreciated.对此的任何指示将不胜感激。

Kuberentes uses different DNS schemes for PODs. Kuberentes 对 POD 使用不同的 DNS 方案。

The DNS schema for a Pod in the default NS with IP 172.17.0.3 is:在 IP 172.17.0.3 的默认 NS 中 Pod 的 DNS 架构是:

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.如果要使用 DNS 名称,则必须使用服务。 For a Service test in the default NS the DNS record is:对于默认 NS 中的服务测试,DNS 记录为:

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/你可以在这里查看: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM