Kubernetes - DNS / Endpoint for POD

I've a Kube-cluster running. I'm trying to access a service externally(not within cluster nor machine - through internet) deployed in a kubernetes pod through DNS(should resolve to ip address of POD) . I got the DNS for the POD but kube-dns is internal DNS. I can only use the DNS name for a service from inside the cluster. Since my service type is Nodeport, I can connect to the service using the IP of the machine. But how can i map POD ip address to machine(server) ip address such  that the service is available publicly.



  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

  • post-author-pic
    Sid R
    11-27-2018

    too many replies for my question from me??? Apologies guys!!1 Please let me know if the question is vague

  • post-author-pic
    Will B
    11-27-2018

    It really depends on where you need to access the service from (externally). If it's just from your local machine for testing purposes, you could simply add it to your local hosts file. If you're just accessing it from an internal company network, you could set it up in your internal company DNS (if you have one). If it needs to be accessible to everyone on the internet, you would need to buy a domain and have it route to a static IP address that can be used to access your service.

  • post-author-pic
    Sid R
    11-27-2018

    So that mean a pod ip address doesnot need to be mapped with cluster IP? Like for example, a pod with ip: 10.0.0.65 is serving a flask application on port 5000 and i need to access this application outside of cluster.(not within in cluster, internet). what  I'm looking for is 10.0.0.65:5000 needs to be mapped to cluster-ip:nodeport to access this application by everyone. And then I can associate the 

     cluster-ip:nodeport to the domain. 

  • post-author-pic
    Will B
    11-27-2018

    The cluster IP is on the virtual network internal to the cluster. This virtual network is purely internal, so you won't be able to use the cluster IP externally. If you are using a NodePort service, use the public IP of any of your cluster servers that has a kubelet on it (any worker node). The port would be the NodePort port that is associated with the NodePort service, so you would access it using $node_public_ip:$nodeport.


    Also, if this is for real-world production stuff I would recommend looking into using an Ingress: https://kubernetes.io/docs/concepts/services-networking/ingress/

  • post-author-pic
    Sid R
    11-28-2018

    Hey Will. Thanks for your suggestion on ingress. it helped me undertand few things. but doesn't really addressed my concern. As per my understanding ingress puts forth the internally hosted service for external access. 

Looking For Team Training?

Learn More