I’d like to call kubectl run
that allows to specify environment values with the syntax: --env=nameOfVar=valueOfVar
.
I have this construct:
env=()
for v in var1 var2 var2; do
env+="--env=$v=${!v}"
done
kubectl run mycontainer "${env[@]}"
In this way, I can pass the value of existing variables to kubectl.
It works ok, except when the value of a var contains spaces.
How can I delimiter arguments correctly to kubectl
?
I’ve tried other variations like:
env=
for v in var1 var2 var2; do
env="$env --env=$v=${!v}"
done
kubectl run mycontainer "$env"