5

I've looked over the documentation and browsed the source, but I can't seem to figure out how to do this. Is there any way to send query string parameters along with the path when implementing a Kubernetes liveness probe?

The string I am sending, which looks something like this:

/api/v1?q=...

becomes URL-encoded and hits the server as:

/api/v1%3fq=...

As I have no such route on this particular API, I get a 404, and Kube reaps the pods after the allotted timeout.

Is there any way to define query string parameters to liveness probes and/or trick the URI encoder to allow query string parameters?

Josh
  • 83
  • 1
  • 6

3 Answers3

4

EDIT: This should now be fixed in Kubernetes 1.3. Thanks to Rudi C for pointing that out.

Liveness probes in Kubernetes v1.2 don't support passing query parameters.

This Issue in the Deis Controller repo has a good explanation. The gist is that the LivenessProbe.HttpGet.Path is treated as a true URL path (which needs the "?" to be escaped as "%3f").

I've opened a feature request Issue against Kubernetes to discuss adding query parameter(s).

As a workaround, you could use an exec livenessProbe that included the query parameters (as long as your container includes something like wget or curl):

livenessProbe:
  exec:
    command:
    - wget
    - /api/v1?q=...
CJ Cullen
  • 5,452
  • 1
  • 26
  • 34
  • This was going to be my backup strategy - we use very stripped down pods that don't include curl/wget, but it seems duty is calling here...thank you for the reply! – Josh Jul 22 '16 at 20:56
  • 1
    I think Rudi is right. This should now work directly in >= 1.3.0. – CJ Cullen Jul 22 '16 at 21:51
3

Which version are you running? The escaping is a bug that was supposed to be fixed in 1.3:

https://github.com/kubernetes/kubernetes/pull/25064

Not perfect, but it doesn't require additional API fields in the YAML.

Rudi C
  • 121
  • 3
0

If you have some kind of token authorization (via get parameter) and you have health check on root (service-name/), you should omit the slash, for example:

readinessProbe:
  httpGet:
    path: ?token=${TOKEN}
    port: 80
    scheme: HTTP

I had to look through PR changes to find the way to specify it

Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96