how to use Kubernetes DNS for pods?

孤街浪徒 提交于 2019-12-05 00:37:07

UPDATE

According to the docs, the format is now:

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

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

ORIGINAL ANSWER:

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

See this issue : https://github.com/kubernetes/kubernetes/issues/13552

UPDATE:

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

in short:

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.

jolestar

Kubernetes statefulset support associate a service name, and define pod dns name by the service name.

Such as your create a zk daemonset, and a zk service, then the dns name of zk daemonset's first pod is zk-0.$(namespace).svc.cluster.local

more details see: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/

Important: The service must be “headless” for this to work, that is it's .spec.clusterIP must be None.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!