Understanding kubectl run command

4/23/2020

I am tryng to create a pod using kubectl run by creating an yaml file, where first command is creating container but showing state as error and second one is creating with out any issue. what is the difference between these commands?

master $  kubectl run --restart=Never --image=busybox static-busybox --command -- sleep 1000 --dry-run -o yaml //Error container

master $  kubectl run --restart=Never --image=busybox static-busybox --dry-run -o yaml --command -- sleep 1000 //working command
-- DevOpsGeek
kubectl
kubernetes

2 Answers

4/23/2020

In the first one parameters --dry-run -o yaml are applied to the command you run in the container (sleep), in the second one, they are applied to your kubectl execution

-- SmasherHell
Source: StackOverflow

4/23/2020

As per the syntax of the kubectl run command needs to be at the end. That's precisely the reason why first command is not working but second one is working.

Usage:
  kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json]
[--command] -- [COMMAND] [args...] [options]
-- Arghya Sadhu
Source: StackOverflow