Hello,
I'm looking from a way from client-go to get current node name or node hostname when the code is running in a pod in the cluster (via a rest.InClusterConfig()).
Is it possible ?
It seems that no such function is supplied by client-go. you can try :
$ curl -Gs http://localhost:10255/pods/ | grep -o '"nodeName":"[^"]*"' | head -n 1
you can inject the node name or host IP into environment variables in a pod using the downward API
see https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-pod-fields-as-values-for-environment-variables for more info
/close
@liggitt: Closing this issue.
In response to this:
you can inject the node name or host IP into environment variables in a pod using the downward API
see https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-pod-fields-as-values-for-environment-variables for more info
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Most helpful comment
you can inject the node name or host IP into environment variables in a pod using the downward API
see https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-pod-fields-as-values-for-environment-variables for more info
/close