Hi,
Is there a way I can get hold of the underlying physical hostname within the docker container entrypoint script soon after it is launched? k8s doesn't seem to set any env variables to access this. Currently I use a hacky way of mounting /etc/hostname within the container and read the hostname from there. Also does /pods endpoint work since the pod may not be entirely setup at this stage.
Thanks!
The only way you can know the hostname is to query the Kubernetes API, for
now. In general, we'll say you should not ask that question - it leads to
couplings that you don't really want.
Once a pod is accepted by the API it is available through the API.
On Jul 28, 2015 9:28 AM, "Sanjana J Bhat" [email protected] wrote:
Hi,
Is there a way I can get hold of the underlying physical hostname within
the docker container entrypoint script soon after it is launched? k8s
doesn't seem to set any env variables to access this. Currently I use a
hacky way of mounting /etc/hostname within the container and read the
hostname from there. Also does /pods endpoint work since the pod may not be
entirely setup at this stage.Thanks!
—
Reply to this email directly or view it on GitHub
https://github.com/GoogleCloudPlatform/kubernetes/issues/11932.
Please re-open if that doesn't answer your question.
I agree that using the hostname programmatically is probably a bad idea, but it can be valuable to annotate telemetry emitted from a container (metrics/logs) with a physical hostname, to facilitate identification of host-level issues. I'd be in favor of this feature.
Most helpful comment
I agree that using the hostname programmatically is probably a bad idea, but it can be valuable to annotate telemetry emitted from a container (metrics/logs) with a physical hostname, to facilitate identification of host-level issues. I'd be in favor of this feature.