Imperative command for CKA/CKAD Exam

Imperative command 1:

**kubectl run pod1 --image=nginx --labels=my=pod1 --command -- sleep 100 --dry-run=client -o yaml > mypod.yaml**

Imperative command 2:

kubectl run pod11 --image=nginx --labels=my=pod1 --dry-run=client -o yaml --command -- sleep 1000 > mypod.yaml

The 1st one creates the pod instead . Do I always have to append the --command --sleep 1000 at end as second one works ?

yes you should. anything after - - (space) will take treat it like arguments.

1 Like

If you are giving the pod a command, then the

--command -- sleep 1000

or whatever the command is if not sleep must be the last arguments to kubectl after everything else.

What follows > is not arguments to kubectl, it indicates where to send the output of kubectl which would otherwise be printed to the terminal

1 Like