-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
$(HOSTNAME) not replaced in args #57726
Comments
I'm not 100% sure on the label... |
/sig scheduling |
/remove-sig scheduling |
You could use the downward API to expose the pod name: |
@cjcaj Thanks for the tip. I think this is still a valid issue because you can access HOSTNAME as the environment variable (i.e. My current workaround is to execute the command from bash as such:
|
I would like to use this also. HOSTNAME to be replaced in arguments. In AWS for now the NODE name is different from hostname. NODE name is set as AWS internal hostname, the hostname is from our organization. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
I also vote for this feature request |
What's wrong with using the downward api for this? (Beside I couldn't find the doc with google, which lead me here ;)). @prestonvanloon The variables in command/args aren't really env variable. They can only refer to the variables defined in the manifest, which is why without setting HOSTNAME yourself (e.g via downward api) it won't be available. |
/remove-lifecycle stale |
@discordianfish my specific use case is to use the hostname of a pod created by some deployment. Does the downward API provide this as a command line argument or simply making it available as an environment variable? If the case is the latter, then I'm in the same spot. I can already access the HOSTNAME via environment variable, but I can't intuitively provide it as a command argument. |
@prestonvanloon It makes it available as env variable and available for templating. Just try setting HOSTNAME via the downward api and you should be able to refer to it in your args like you do, e.g:
|
Can this be closed? If anything this is a documentation issue. I see how it's confusing that these arg variable references look like environment variables although they are not. |
This is not true for provider aws. In this case it will put the internal aws name of the instance, not the hostname |
@cristifalcas It will pull in the kubernetes node name. Is there a reason for having a different name there than your hostname? Not sure what exact setup you run on AWS, but I'd argue the node name should ideally be the same as the hostname. |
It's a bug in k8s: #54482 |
@discordianfish Please look at my original example, I need the pod's name, not the node's name. |
@prestonvanloon Then use the pod name instead? Did you read the docs? https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#capabilities-of-the-downward-api |
@discordianfish Thanks! That would work for me. It is not as ideal as using the $HOSTNAME, but it would solve my problem. I'll go ahead and close this as my issue has a workaround with the downward API. |
Just want to add this for completion because it took me some time to figure out
|
Was there any update on that, I was trying to use the env variable from my worker node, When I tried to use that env in POD yaml it just proving the string not the actual value as shown below. apiVersion: v1
on container I'm getting below output. / # echo $DB_NAME |
Maybe you could use $(DB_NAME) instead. |
There are certain nuances to working with environment variables in Kubernetes YAMLs. See kubernetes/kubernetes#57726 Also add a spinner to QA wizard while processing. Signed-off-by: Harikrishnan Balagopal <harikrishmenon@gmail.com>
There are certain nuances to working with environment variables in Kubernetes YAMLs. See kubernetes/kubernetes#57726 Also add a spinner to QA wizard while processing. Signed-off-by: Harikrishnan Balagopal <harikrishmenon@gmail.com>
There are certain nuances to working with environment variables in Kubernetes YAMLs. See kubernetes/kubernetes#57726 Also add a spinner to QA wizard while processing. Signed-off-by: Harikrishnan Balagopal <harikrishmenon@gmail.com>
Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug
What happened:
Given the following pod configuration:
This pod echoed literately
$(HOSTNAME)
.What you expected to happen:
The pod to echo
command-demo
(the pod name).How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
This works for other environment variables such as
KUBERNETES_SERVICE_HOST
.Environment:
kubectl version
):minikube version: v0.21.0
uname -a
):Linux naydra 4.13.0-21-generic #24-Ubuntu SMP Mon Dec 18 17:29:16 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: