0

I am adding liveness probe and readiness probe using Exec probe.
My config looks like this:

readinessProbe:
    exec:
      command: "/usr/bin/jps -l | grep QueueProcess"
    periodSeconds: 10 
    failureThreshold: 2
    successThreshold: 2

When the above one didn't work. I modified this and also tried:

readinessProbe:
     exec:
       command: ["/usr/bin/jps", "-l", "|", "grep","QueueProcess"]
     periodSeconds: 10 
     failureThreshold: 2
     successThreshold: 2

On running kubectl describe pod, got following output:

  Normal   Created           37s                  kubelet             Created container app1
  Normal   Started           37s                  kubelet             Started container app1
  Warning  Unhealthy         6s (x3 over 26s)     kubelet             Readiness probe failed: invalid argument count
usage: jps [-help]
       jps [-q] [-mlvV] [<hostid>]

Definitions:
    <hostid>:      <hostname>[:<port>]

I tried another application, where I am running grpcurl to call health check:

readinessProbe:
    exec:
      command: ["grpcurl", "-plaintext", "-protoset", "/app/HealthCheck.protoset", "localhost:8123", "service.HealthCheckService/GetHealthCheck","|", "jq", ".", "|","grep","200"]
    periodSeconds: 10 
    failureThreshold: 2
    successThreshold: 2

On running kubectl describe pod for this one, I got:

  Normal   Created           23s                kubelet             Created container app2
  Normal   Started           23s                kubelet             Started container app2
  Warning  Unhealthy         3s (x2 over 13s)   kubelet             Readiness probe failed: Too many arguments.
Try 'grpcurl -help' for more details.

Both of these are failing. The question, how can I write an Exec probe, which has a pipe(or multiple pipe) in it?

I am using EKS v1.18.
(Both the above configs belong to different applications.)

kadamb
  • 1,532
  • 3
  • 29
  • 55

1 Answers1

3

You need to actually use a shell, since that's a shell feature. sh -c "foo | bar" or whatever. Also remember that all the relevant commands need to be available in the target image.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • Have added more information, can you have a look. – kadamb May 09 '21 at 23:06
  • The array form is correct but, again, you need to use a shell if you want shell features. The command is run _literally_. `command: [sh, -c, "/usr/bin/jps -l | grep QueueProcess"]` – coderanger May 09 '21 at 23:08