kuberneteskubernetes-dns

kubernetes-cli command to get dns of a kubernetes resource


I have gone through the doc mentioned here gitlink as well as doclink

But my job would be a whole lot easier if I could get the dns of a resource type by using any kubernetes command. Also tried this commands-link

For example, i would like to get the dns name of a service db-service running in dev namespace inside svc.cluster.local

db-service.dev.svc.cluster.local

Any pointers ?


Solution

  • If you need to, you can query that in a pod:

    How do I run a container from the command line in Kubernetes (like docker run)?

    Retrieve the full name of a service in Kubernetes

    using a pod which has some DNS utils

    kubectl run tmp-shell --rm -i --tty --image tutum/dnsutils -- /bin/bash
    

    you can then run

    root@tmp-shell:/# nslookup db-service
    Server:     10.2.32.10
    Address:    10.2.32.10#53
    
    Name:   db-service.dev.svc.cluster.local
    

    for a one-liner, see: https://serverfault.com/questions/929211/kubernetes-pod-dns-resolution