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.yaml
This does NOT:
k run nginx --image=nginx --restart=Never --command -- env --dry-run=client -o yaml > nginx.yaml
I 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.
2
Answers
Everything after
--
is a positional argument (until the>
which is a shell metachar), not an option.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:So you can’t freely swap "parameters" places. Only these options can be freely set
Then 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.