I found that creating a yaml object description using --dry-run=client and providing --command only works when the provided arguments are in a very specific order.
This works:
k run nginx --image=nginx --restart=Never --dry-run=client -o yaml --command -- env > nginx.yamlThis does NOT:
k run nginx --image=nginx --restart=Never --command -- env --dry-run=client -o yaml > nginx.yamlI feel a bit confused because the version that does not work looks a lot more intuitive to me then the one that does work. Ideally both should work in my opinion. Is this intended behavior? I can't find any documentation about it.
Everything after -- is a positional argument (until the > which is a shell metachar), not an option.
Ideally both should work in my opinion.
Unfortunately, the commands you presented are not the same. They will never work the same either. This is correct behaviour. Double dash (--) is of special importance here:
a double dash (
--) is used in most Bash built-in commands and many other commands to signify the end of command options, after which only positional arguments are accepted.
So you can't freely swap "parameters" places. Only these options can be freely set
--image=nginx --restart=Never --dry-run=client -o yaml --commandThen you have -- env (double dash, space, and another command). After -- (double dash and space) only positional arguments are accepted.
Additionally, > is shell meta-character to set redirection.