TL;DR when you set the cluster domain, this should Just Work™ in Kubernetes 1.7+ but not before
David – what Kubernete version are you running? I just went down a rabbit hole because our /etc/hosts did not look like this code[0] suggests it should. Turns out, there was a bug before 1.7[1] that causes /etc/hosts to not actually be written at the right times. >From my understanding the `hostname -f` mechanism[2][3] ultimately takes its information from the line like 10.3.4.5 podname podname.cluster-domain but even though we set a cluster domain, I only got the short name. Issue 44473 suggests that this is fixed in 1.7 but I have no such cluster to test it against. /MR [0] https://github.com/kubernetes/kubernetes/blob/7be29bd9b6913e2f39b44a72a5f46e6f33244410/pkg/kubelet/kubelet_pods.go#L300-L304 [1] https://github.com/kubernetes/kubernetes/issues/44473 [2] https://linux.die.net/man/1/hostname [3] https://linux.die.net/man/3/gethostbyname On Wed, Sep 6, 2017 at 5:18 PM David Rosenstrauch <dar...@darose.net> wrote: > On 2017-09-05 6:19 pm, 'Tim Hockin' via Kubernetes user discussion and > Q&A wrote: > > We do not have a mechanism to express what you want to express, then. > > You control the cluster suffix and the subdomain, and the pod name, > > but even with all of those in play, the hostname comes out as > > `<pod>.<subdomain>.svc.<suffix>`, I am pretty sure. I am open to > > proposals on how to allow what you want. > > > Docker allows us to launch containers this way. For example, I can > perform the following: > > sudo docker run -d -h "$(openssl rand -hex 8).ourdomain.com" -p > 33334:33333 the-container-image > > And then the container that gets launched will successfully report back > a fully-qualified hostname that includes the domain name when I issue a > hostname -f. > > > In answer to your comment about proposals on how to allow what I want, I > guess conceptually I'd think the following: > > Kubernetes is already setting the hostname for each pod that gets > launched - usually in the form of > <service-name>-<replicaset-id>-<some-unique-hash>. I guess then what > would make sense to me is that this be changed to be > <service-name>-<replicaset-id>-<some-unique-hash>.<cluster-domain>. In > most cases, then, your fully-qualified pod hostname would look like > abc-1234567-12345.cluster.local. But if you chose to override the > cluster domain on your cluster, you could then easily make it change to > abc-1234567-12345.yourdomain.com. > > Any reason why this couldn't work, or shouldn't be done? (I.e., any > particular reason why a pod hostname should not always be set to a > fqdn?) > > Thanks, > > DR > > -- > You received this message because you are subscribed to the Google Groups > "Kubernetes user discussion and Q&A" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to kubernetes-users+unsubscr...@googlegroups.com. > To post to this group, send email to kubernetes-users@googlegroups.com. > Visit this group at https://groups.google.com/group/kubernetes-users. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group. To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscr...@googlegroups.com. To post to this group, send email to kubernetes-users@googlegroups.com. Visit this group at https://groups.google.com/group/kubernetes-users. For more options, visit https://groups.google.com/d/optout.