How should I set up FQDN identity for kubernetes pods in local cluster?

jtee picture jtee · Apr 11, 2018 · Viewed 7.9k times · Source

This question is relevant to local cluster (kubernetes 1.10+ version, Linux). After creating a StatefulSet to manage several pods, I met a use case that requires setting up FQDN identity for the pods.

For instance, I wish to have the first pod with FQDN identity of <some-statefulset>-0.<some-subdomain>.default.svc.cluster.local. Desired behavior can be achieved by adding <IP-address> <some-statefulset>-0.<some-subdomain>.default.svc.cluster.local into /etc/hosts file, but I want to have the FQDN to be identified automatically in the local cluster without changing the /etc/hosts file.

Not sure whether I need to enable some settings when starting the local cluster.

Answer

Sandy picture Sandy · Aug 9, 2019

By default the cluster.local is the internal domain. To reach service from pods within the cluster,

svc_name.namespace_name.cluster.local