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

allow the target to be set to http://kubernetes_host_ip:30556 #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mpnally
Copy link
Contributor

@mpnally mpnally commented Oct 26, 2016

No description provided.

@mpnally
Copy link
Contributor Author

mpnally commented Oct 26, 2016

I added code to access the K8S management API within the cluster to retrieve the hostIP address for the node on which the pod is running.

Before going down this path, I tried 2 other approaches and struck out with each. One was to try to use the feature referenced in this pull request that Jeremy pointed out: kubernetes/kubernetes#27880. Unfortunately, this gives you the host name, not its IP address. Also, it is the hosts external name, as it is known outside the cluster. It is not resolvable within the cluster (its not in DNS, at least)

I also tried Jeremy's suggestion of parsing /proc/net/route. On the machines I looked at, there is nothing useful in that file. I spent some time rummaging around in other files and did not find anything helpful

var token = fs.readFileSync('/var/run/secrets/kubernetes.io/serviceaccount/token').toString()
var cert = fs.readFileSync('/var/run/secrets/kubernetes.io/serviceaccount/ca.crt').toString()
var ns = fs.readFileSync('/var/run/secrets/kubernetes.io/serviceaccount/namespace').toString()
var podName = process.env.POD_NAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite the assumption here. We should document how to use this and/or make this a configuration item that can be set in the YAML itself and overridden via an environment variable. Also, we do not do any sort of validation on the value and just assume its set. We should handle this.

@coveralls
Copy link

coveralls commented Nov 1, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling a721771 on kubernetes-hostIP-target into 4f30f2f on master.

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

Successfully merging this pull request may close these issues.

3 participants