Retrieve the full name of a service in Kubernetes

大憨熊 提交于 2020-08-10 23:01:54

问题


By default,according to k8s documentation, Services are assigned a DNS A record for a name of the form my-svc.my-namespace.svc.cluster-domain.example.

Is there a command to retrieve the full name of a service?


回答1:


You can do a DNS query from any pod and you would get the FQDN.

# nslookup api-server
Server:     10.96.0.10
Address:    10.96.0.10#53

Name:   api-server.default.svc.cluster.local
Address: 10.104.225.18

root@api-server-6ff8c8b9c-6pgkb:/#

cluster-domain.example is just a example in the documentation. cluster.local is the default cluster domain assigned. So the FQDN of any service by default would be <service-name>.<namespace>.svc.cluster.local.

You don't need to use the FQDN to access services - for services in same namespace, just the service name would be enough. For services in other namespaces, <service-name>.<namespace> would be enough as kubernetes would automatically set up the DNS search domains.



来源:https://stackoverflow.com/questions/59559438/retrieve-the-full-name-of-a-service-in-kubernetes

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