kubernetes: kubectl run overrides envFrom doesn't add env vars
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
/kind bug
/kind feature
What happened:
Calling kubectl run with overrides injecting environment from configmap doesn’t inject environment
What you expected to happen:
I expect to see environment variables from the config map in the process
How to reproduce it (as minimally and precisely as possible):
kubectl create configmap my-config --from-literal=FOO=BAR
kubectl run -i --rm --tty ubuntu --overrides='
{
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "app",
"image": "ubuntu",
"envFrom": [
{
"configMapRef": {
"name": "my-config"
}
}
]
}
]
}
}
}
}
' --image=ubuntu --restart=Never -- bash -c "sleep 3 && env"
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version
):
Client Version: version.Info{Major:“1”, Minor:“6”, GitVersion:“v1.6.2”, GitCommit:“477efc3cbe6a7effca06bd1452fa356e2201e1ee”, GitTreeState:“clean”, BuildDate:“2017-04-19T22:51:55Z”, GoVersion:“go1.8.1”, Compiler:“gc”, Platform:“darwin/amd64”} Server Version: version.Info{Major:“1”, Minor:“6”, GitVersion:“v1.6.1”, GitCommit:“b0b7a323cc5a4a2019b2e9520c21c7830b7f708e”, GitTreeState:“clean”, BuildDate:“2017-04-03T20:33:27Z”, GoVersion:“go1.7.5”, Compiler:“gc”, Platform:“linux/amd64”}
- Cloud provider or hardware configuration**: AWS/kops
- OS (e.g. from /etc/os-release): OSX
- Kernel (e.g.
uname -a
):
Darwin WLT041147 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
- Install tools:
- Others:
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (8 by maintainers)
So now, I think only
env
is in the option list ofkubectl run
. Considering this is related to ticket #26299, @bgrant0607, not sure if we can propose a new optionenvFrom
forkubectl run
. As for now,envFrom
supports two kinds of sources: configmap and secrets, so the new option would play like:kubectl run nginx --image=nginx --envFrom='ConfigMapRef=abc' --envFrom='SecretRef=def'
Do you think this new option is reasonable?Hello, I tried dry running it and looks like it is missing in the spec.
No envFrom secret or configmap.
EDIT: Figured it out. It is necessary to remove
"spec"
and"template"
from the override:@lev-kuznetsov Did you test with
--dry-run -o yaml
to see whatkubectl run
would generate? I’ve tried something similar, but my template looks like:till now, I think the change is only limited to kubectl
As a workaround, I currently create a pod by piping echo of a full descriptor with the configmap and a blocking command and then I exec my process in the pod, kind of like this:
My actual use case is that I’m trying to run unit tests as part of my CI process and I’d like to take advantage of secrets storage except there doesn’t appear to be a way to block for a job completion, and even if attach did work it would be clunky, I seem to be losing the beginning of the input hence the sleep.