I'm assuming-sh is the shell but why is -c required?

Ryebridge:
With regard to the following:

readinessProbe:
exec:
command:
- sh
- c
- ‘wget - http://hostname:80

…I’m assuming-sh is the shell but why is -c required ?

Vitor Jr.:
c from command

Vitor Jr.:
sh -c <will run your command here>

Ryebridge:
Thanks Victor but why not just have all on one line like this:

eadinessProbe:
exec:
command:
- sh -c wget - http://hostname:80

Vitor Jr.:
Cause it won’t work :slightly_smiling_face:

Vitor Jr.:
It’s an array

Vitor Jr.:
You need to specify each argument as a different element

Vitor Jr.:
for a small command, you could just ignore the sh -c and execute the command

Vitor Jr.:
example:

ReadinessProbe:
   exec:
    command:
     - sleep
     - 10

Vitor Jr.:
One command with one argument

Vitor Jr.:
But suppose you had a lot of arguments, like this:

Vitor Jr.:
ps auxww|grep -v grep|grep -i mysql|xargs echo etc...

Vitor Jr.:
Would be a lot of elements in an array

Vitor Jr.:
So we ‘encapsulate’ in one argument inside a shell execution (sh -c "...")

Vitor Jr.:
And that will look like this:

ReadinessProbe:
   exec:
    command:
     - sh
     - -c
     - "ps auxww|grep -v grep|grep -i mysql|xargs echo etc..."

Vitor Jr.:
Saved a lot of typing :slightly_smiling_face: