Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access physical hostname in the k8s launched docker container entrypoint script #11932

Closed
sanjana-bhat opened this issue Jul 28, 2015 · 3 comments

Comments

@sanjana-bhat
Copy link

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!

@thockin
Copy link
Member

thockin commented Jul 28, 2015

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" notifications@github.com 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
#11932.

@alex-mohr
Copy link
Contributor

Please re-open if that doesn't answer your question.

@joshng
Copy link

joshng commented Jun 6, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants