Syntax for --command with kubectl run in kubernetes

Cloud Climber:
Hi guys, can i use --command “sleep 1000” like this?
Because i am getting:
"exec: \"sleep 1000\": executable file not found in $PATH": unknown

KK:
Yes we can use

KK:
But the command needs to be corrected here, there should be – between the command argument and the sleep command

SHANKAR NAG MACHIRAJU:
you can use this command : kubectl run --restart=Never --image=busybox busybox-pod --command – sleep 1000

Cloud Climber:
Sorry but doesnt collaborate well with " --command – sleep 1000 --dry-run -o yaml > /etc/kubernetes/manifests/static-busybox.yaml"
image.png

KK:
–dry-run and -o yaml should be before --command other wise it will treat as --command arguments

Cloud Climber:
still didnt put them “on the same line” - its not correct right?
image.png

KK:
kubectl run busybox --image=busybox --dry-run -o yaml --command – sleep 1000

KK:
And the output no need to be in the same line

Sahil Rahi:
kubectl run busybox --image=busybox --command sleep 1000 --dry-run -o yaml

KK:
Ya this will also work

Cloud Climber:
thank you, thats what i did at the beggining, but i thought if the describe command shows the sleep 1000 split in 2 lines, it would be considered a fail in the exam :disappointed:

KK:
Can you please share the screenshot of the fail?

Cloud Climber:
nono nothing failed, it was just my opinion that if the describe command shows the sleep 1000 split in 2 lines it would not work

KK:
As per the k8s reference docs , here is the syntax
$ kubectl run NAME --image=image [–env=“key=value”] [–port=port] [–dry-run=server|client] [–overrides=inline-json] [–command] – [COMMAND] [args…]

KK:
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run

KK:

KK:

KK:
Observe how the “sleep 1000” with double quotes it will treat for the --command

KK:
Without doubles will work as expected