I am having an issue with passing a pipe character |
in readiness probe command.
I want to have a probe command:
curl --silent http://localhost:8080/actuator/health | grep --quiet -e '^{\"status\"\:\"UP\".*}$'
Here is how I have defined the probe:
# kubectl get pod my_pod -o yaml
readinessProbe:
exec:
command:
- curl
- --silent
- http://localhost:8080/actuator/health
- '|'
- grep
- --quiet
- -e
- '''^{\"status\"\:\"UP\".*}$'''
Readiness probe fails with a message:
Readiness probe failed: curl: option --quiet: is unknown curl: try 'curl --help' or 'curl --manual' for more information
The error can be reproduce when command is executed without pipe character |
:
curl --silent http://localhost:8080/actuator/health grep --quiet -e '^{\"status\"\:\"UP\".*}$'
For some reason pipe is not interpreted by Kubernetes.
Can you please help me with passing pipe in deployment?
There is no separate endpoint for readiness probes, but we can access events using the kubectl describe pods <POD_NAME> command, for example, to get the current status. Use kubectl get pods command to see the pods' status. Pods and their status and ready states will be displayed, our pod is running as expected.
To increase the readiness probe failure threshold, configure the Managed controller item and update the value of "Readiness Failure Threshold". By default, it is set to 100 (100 times). You may increase it to, for example, 300 .
If the readiness probe fails, the endpoints controller removes the Pod's IP address from the endpoints of all Services that match the Pod. The default state of readiness before the initial delay is Failure . If a container does not provide a readiness probe, the default state is Success .
Readiness probes are configured similarly to liveness probes. The only difference is that you use the readinessProbe field instead of the livenessProbe field. Configuration for HTTP and TCP readiness probes also remains identical to liveness probes.
Kubernetes doesn't run a shell to process commands on its own; it just runs them directly. The closest equivalent in a shell would be
curl '--silent' 'http://...' '|' 'grep' ...
That is, |
here doesn't split two separate commands, because that's shell syntax; without a shell it becomes another parameter to curl
, as do all of the words after it.
You need to provide the shell wrapper yourself:
readinessProbe:
exec:
command:
- sh
- -c
- curl --silent http://localhost:8080/actuator/health | grep --quiet -e '^{\"status\"\:\"UP\".*}$'
You can use alternate YAML syntax to make this a little more readable. (>
means to fold following lines into a single string; -
means to strip leading and trailing whitespace.
readinessProbe:
exec:
command:
- sh
- -c
- >-
curl --silent http://localhost:8080/actuator/health |
grep --quiet -e '^{\"status\"\:\"UP\".*}$'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With