David
David

Reputation: 79

How to pass "--command" to "kubectl run" that also uses "--overrides"

I noticed a strange behavior while experimenting with kubectl run :

So it looks like using --overrides prevents --command to be used.

However, I precisely need to use --command to bypass the array format expected by --overrides (ie. "command": [ "ls", "-lah" ]) because in my use case the command is a placeholder and cannot be known in advance.

FYI: kubectl version=v1.23.1+k3s2

Upvotes: 4

Views: 6914

Answers (1)

Anton
Anton

Reputation: 21

You can bypass the array format by using the args field:

"command": [
 "sh",
 "-c"
],
"args": [ "pwd && id && node YOUR_COMMAND" ]

Upvotes: 2

Related Questions