I'm trying to understand exactly how kubernetes command probes work, but the documentation is quite dry on this.
Every example I found on kubernetes command probes gives the same kind of code:
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
I seems possible to pass any command to the exec object. So my question is:
cat
is one good exec command probe. But any linux command is valid.You can pass any command as an exec
probe.
The healthy of the container is determined by the exit code. If the command succeeds, it returns 0
, and the kubelet
considers the Container to be alive and healthy. Anything different than exit code 0
is considered unhealthy.
Some applications provide binaries/scripts that are made for health checks.
Examples:
rabbitmq-api-check
pg_isready
mysqladmin ping
The use of exec
probe is also useful when you need to define an entire script with the logic of your expected healthiness.