如何将Kubernetes DNS用于Pod? [英] how to use Kubernetes DNS for pods?

查看:112
本文介绍了如何将Kubernetes DNS用于Pod?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GKE上, kube-dns 在我的节点上运行,我可以看到docker容器.

On GKE, kube-dns is running on my nodes, I can see the docker containers.

我确实可以按名称访问服务,这对于所有应用程序都非常有用,在这些应用程序中,负载平衡是一个非常合适的解决方案,但是我将如何使用DNS来访问各个Pod?

I do have access to Services by name, which is great for all these applications where load balancing is a perfectly suitable solution, but how would I use the DNS to access individual pods?

我知道我可以在API中查找特定的Pod,但是我需要自己更新hosts文件,并继续查看Pod列表. DNS应该为我做到这一点,那么在pod中使用DNS意味着什么呢?

I know I can look up specific pods in the API, but I need to update the hosts file myself, and keep watching the pod list. DNS is supposed to do that for me so how is it meant to be used within a pod?

Kubernetes文档说DNS信息需要传递到kubelet,但是我无法访问我所知道的GKE上的信息,因此它是否不是在GKE上以这种方式设置的,或者有什么办法可以激活它?

The Kubernetes doc says the DNS info needs to be passed to the kubelet but I have no access to that on GKE that I know of, so is it just not setup that way on GKE or is there something to do to activate it?

我的某些服务(尤其是zookeeper)本身意识到其他节点,并尝试通过主机名(即pod名称)连接到它们,除非我自己更新hosts文件,否则该失败.我想为此使用集成的DNS服务.

Some of my services (zookeeper in particular) is aware of other nodes on its own, and tries to connect to them by host name (that is pod name) and that fails unless I update the hosts file myself. I would like to use the integrated DNS service for that.

任何有关如何执行此操作的指南将不胜感激.

Any guidance on how to do this would be appreciated.

谢谢

推荐答案

更新

根据文档,格式现在为:

According to the docs, the format is now:

_my-port-name._my-port-protocol.my-svc.my-namespace.svc.cluster.local

在此处查看相关文档: https://kubernetes.io/docs/concepts/services-联网/dns-pod-service/#pods

See the related doc here: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pods

原始答案:

到目前为止,这实际上是不可能的……但是Kubernetes团队正在对此进行研究.

as of this date, this is actually not possible... but it is being looked at by the Kubernetes team.

查看此问题: https://github.com/kubernetes/kubernetes/issues/13552

更新:

从2015年9月开始,DNS可用于Pod 参见PR: https://github.com/kubernetes/kubernetes/pull/13759

DNS is available for Pods since 09/2015 See PR:https://github.com/kubernetes/kubernetes/pull/13759

简而言之:

这将以以下形式提供Pod dns: <podIP>.<namespace>.pod.<clusterSuffix>当前可以被禁用,但是 对于所有广告连播都处于启用状态,也可能处于关闭状态.

This will give pods dns in the form of <podIP>.<namespace>.pod.<clusterSuffix> Currently can be disabled, but is either on for all pods or off.

这篇关于如何将Kubernetes DNS用于Pod?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆