Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support liveness and readiness probe with HTTP check that checks response text #55405

Open
pjfanning opened this issue Nov 9, 2017 · 21 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@pjfanning
Copy link

pjfanning commented Nov 9, 2017

Is this a BUG REPORT or FEATURE REQUEST?:

/kind feature
/sig node

Problem:
This is equivalent to the HAProxy http-check expect string READY (https://www.haproxy.com/documentation/aloha/7-0/haproxy/healthchecks/)
Based http://kubernetes.io/docs/user-guide/liveness/ it appears that the healthz checks only check the HTTP response code.
I'm working with a health check that is a company standard and that returns status strings.

Proposed Solution:
Some capability to check the text of the response to see if it contains a particular string.
This check would probably need to only check the first n characters to prevent issues with memory.
HAProxy also supports an rstring that is a regex but my use case does not require it.

Page to Update:
http://kubernetes.io/docs/user-guide/liveness/

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 9, 2017
@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Nov 9, 2017
@k8s-ci-robot k8s-ci-robot added the sig/node Categorizes an issue or PR as relevant to SIG Node. label Nov 9, 2017
@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Nov 9, 2017
@bgrant0607
Copy link
Member

This could also be done by an exec probe.

@pjfanning
Copy link
Author

Thanks @bgrant0607 - that is the workaround we've been using - but it would be nice not to have a custom shell script that the exec probe calls.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 19, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 18, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@bgrant0607 bgrant0607 reopened this Jun 4, 2018
@bgrant0607 bgrant0607 added sig/network Categorizes an issue or PR as relevant to SIG Network. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Jun 4, 2018
@thockin thockin added the triage/unresolved Indicates an issue that can not or will not be resolved. label Mar 8, 2019
@danielqsj
Copy link
Contributor

Hi @bgrant0607 @thockin @liggitt , does this feature sound reasonable to you ?
I'd like to submit a PR to support this feature if you agree to do it.

@thockin
Copy link
Member

thockin commented May 9, 2019

I don't hate it, but I don't love it. I can't help but think there has to be some opaque way to do this internal to your app (or in a sidecar that hits the real URL and then converts string-valiation into 2xx or 4xx).

Is there really no better way?

@thockin thockin removed the triage/unresolved Indicates an issue that can not or will not be resolved. label May 9, 2019
@timotheobborges
Copy link

Hi,
I have the same company standard here (request a default url path [http://app_uri/status] and check if there is a string "OK"). This feature is common in load balancers to check the healthy of the web application. It would be great if it would be implemented in kubernetes Rediness/liveless httpget probe
best regards!

@dheerajdwivedi
Copy link

dheerajdwivedi commented Nov 22, 2019

Did we conclude on this ?
I would like to pick this up.

Here is the proposed config format:

kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-http
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/liveness
    args:
    - /server
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
        - name: Custom-Header
          value: Awesome
        response
          headers:
            status: []
          body:
            - content-type: application/json
              matchExpression: $.response.code
              value: 2004
      initialDelaySeconds: 3
      periodSeconds: 3

@jproig
Copy link

jproig commented Mar 25, 2021

The proposed solution will be useful for us aswell.
We implemented Atlassian Jira DataCenter version, and we are trying to use the /status healtcheck, that URL always returns a 200 code, but the content in the body reflects the real status.

@HariSekhon
Copy link

HariSekhon commented Apr 9, 2021

+1 for HTTP content checks.

Many HTTP applications have JSON HTTP endpoints containing their status so checking for 200 OK is not sufficient.

Also, when shutting down services it's common for services behind load balancers to change a status content semaphore to allow for graceful removal from a serving pool.

Kubernetes should support at least:

  • HTTP string content checks
  • HTTP regex content checks

and preferably also:

  • HTTP JSON field string content checks
  • HTTP JSON field regex content checks

@mscholze
Copy link

mscholze commented Jun 1, 2021

+1 for HTTP content checks.

Found that issue when I've googled for http content checks for liveness and readiness probes. Also found some workarounds with shell + curl, but then we have to modify the image when curl is not installed.

@adisky
Copy link
Contributor

adisky commented Jun 25, 2021

/triage accepted
/priority low
We will evaluate it later!!

@k8s-ci-robot
Copy link
Contributor

@adisky: The label(s) priority/low cannot be applied, because the repository doesn't have them.

In response to this:

/triage accepted
/priority low
We will evaluate it later!!

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jun 25, 2021
@adisky
Copy link
Contributor

adisky commented Jun 25, 2021

/priority backlog

@k8s-ci-robot k8s-ci-robot added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Jun 25, 2021
@khenidak
Copy link
Contributor

I don't think we should be implementing this. Parsing the entire response in order to identify a certain health signal just adds complexities we don't need. Take the following examples:

  • container x returns some large response. That is an added load on kubelet health check go routines.
  • What happens to failures? e.g. we couldn't find string xyz or header abc these needs to be logged somewhere for users to debug.

The use-case is very specific to content-type and content and does seem like something users should warp in custom script that walks through the custom logic needed to match to a custom health signal beyond HTTP response status.

@k8s-triage-robot
Copy link

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. and removed triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Feb 8, 2023
@thockin
Copy link
Member

thockin commented Feb 9, 2023

/triage accepted

This probably warrants a small KEP to discuss.

Proposals are welcome

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 9, 2023
@SergeyKanzhelev
Copy link
Member

substring is implemented in may systems like https://cloud.google.com/load-balancing/docs/health-check-concepts#criteria-protocol-http. So it makes sense to implement it in kubelet as well. It is a great quality of life improvement for kubernetes probes.

Some notes on the potential implementation:

  1. We will need to introduce a limit - how many bytes we check for the substring. Not parse the entire response
  2. Maybe we can limit this capability to the probes configured without custom host. Using it with custom host may expose some information from the node that we may not want to expose otherwise (
    // Note: Until https://issue.k8s.io/99425 is addressed, this user-facing failure message must not contain the response body.
    ).

@k8s-triage-robot
Copy link

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. and removed triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Feb 23, 2024
@thockin
Copy link
Member

thockin commented Mar 14, 2024

/triage accepted

This remains a plausible feature request. Needs an owner and a KEP.

Question: substring on regexp?
Question: max body-len to parse?

One issue is that pod probes are sometimes used to derive external LB health-checks. Need to define how this change would affect that.

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests