Kubernetes custom domain name

6/28/2018

I'm running Kuberentes with a Minikube node on my machine. The pods are accessing each other by their .metadata.name, and I would like to have a custom domain to that name.

i.e. one pod accesses Elastic's machine by elasticsearch.blahblah.com

Thanks for any suggestions

-- aclokay
kubernetes

1 Answer

6/29/2018

You should have DNS records for pods by default due to kube-DNS addon enabled by default in minikube.

To check kube-dns addon status use the below command:

kubectl get pod -n kube-system

Please find below how cluster add-on DNS server works:

An optional (though strongly recommended) cluster add-on is a DNS server. The DNS server watches the Kubernetes API for new Services and creates a set of DNS records for each. If DNS has been enabled throughout the cluster then all Pods should be able to do name resolution of Services automatically.

For example, if you have a Service called "my-service" in Kubernetes Namespace "my-ns" a DNS record for "my-service.my-ns" is created. Pods which exist in the "my-ns" Namespace should be able to find it by simply doing a name lookup for "my-service". Pods which exist in other Namespaces must qualify the name as "my-service.my-ns". The result of these name lookups is the cluster IP.

Kubernetes also supports DNS SRV (service) records for named ports. If the "my-service.my-ns" Service has a port named "http" with protocol TCP, you can do a DNS SRV query for "_http._tcp.my-service.my-ns" to discover the port number for "http".

The Kubernetes DNS server is the only way to access services of type ExternalName.

You can follow Configure DNS Service document for configuration instructions.

Also, you can check DNS for Services and Pods for additional information.

-- Akar
Source: StackOverflow