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

load balancer health check for kube-apiserver #3537

Merged

Conversation

tkashem
Copy link
Contributor

@tkashem tkashem commented May 3, 2020

No description provided.

@tkashem
Copy link
Contributor Author

tkashem commented May 4, 2020

@abhinavdahiya let me know if this is the right place for this doc, otherwise I will move it.

/assign @abhinavdahiya

@abhinavdahiya
Copy link
Contributor

Thanks for the detailed doc @tkashem !

I think the next step will be to make this doc discoverable by linking this doc from the code that defines these healthchecks in data/data/{aws,gcp} ..

@abhinavdahiya abhinavdahiya requested review from abhinavdahiya and removed request for jhixson74 and mtnbikenc May 4, 2020 22:19
@abhinavdahiya abhinavdahiya reopened this May 4, 2020
- Existing connections are not cut off hard, they are allowed to complete gracefully.

## Load Balancer Health Check Probe
`kube-apiserver` provides graceful termination support via the `/readyz` health check endpoint. When `/readyz`reports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space in front of "reports"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


Now let's walk through the events (in chronological order) that unfold when a `kube-apiserver` instance restarts:
* E1: `T+0s`: `kube-apiserver` receives a TERM signal.
* E2: `T+0s`: `/readyz` starts reporting `failure` to signal to the load balancer that a shut down is in progress.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everywhere in the doc: load balancers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* E3: `T+70s`: `kube-apiserver` (the http server) stops listening:
* `/healthz` turns red.
* Default TCP health check probe on port `6443` will fail.
* Any new request forwarded to it will fail, most likely with a `connection refused` error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or GOAWAY for http/2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

* E5: `T+70s+60s`: The apiserver process exits.

An important note to consider is that today the time difference between `E3` and `E2` is `70s`. This is known as
`shutdown-delay-duration` and is configurable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be clear: not configurable by the user, but by the devs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Let's plot the events as it happens when a load balance determines that a `kube-apiserver` is unhealthy and
takes it out of service. This considers a worst case scenario:
* P1: T+0s: `/readyz` starts reporting red.
* P2: T+10s: first probe initiated.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be clear that this is an example. P2 could be right at T+0s, depending on the alignment of the probe request interval.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it clear that this is a worst case scenario to calculate at most 30s


We assume the following:
* Each health check request is independent and lasts the entire interval.
* The time it takes for the instance to respond does not affect the interval for the next health check.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know from aws/gcp docs that this is really the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is true for aws, i copied them verbatim from aws doc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link the docs, to make this easy to check? Seems like it's the classic-LB docs, but the installer uses network load balancers (classic LBs are aws_elb).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find a doc that describes this for network load balancer exclusively. I think the health check mechanics should be the same for classic, application and network LB. Maybe we can ask this question to our AWS account rep.

On the other hand, what we stipulate above must hold true for all health checks universally. Otherwise if we allow one interval to bleed into another then we don't have a deterministic "at most".

@tkashem tkashem force-pushed the kube-apiserver-health-check branch 4 times, most recently from 28371c9 to b8d4bb5 Compare May 6, 2020 18:50

## Load Balancer Health Check Probe
`kube-apiserver` provides graceful termination support via the `/readyz` health check endpoint. When `/readyz` reports
`ok` it indicates that the apiserver is ready to serve request(s).
Copy link
Member

@wking wking May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ok -> 200 OK? I expect LBs to care about HTTP status codes and not about the response body. And your ok is likely shorthand for the 200 status, but I think explicitly saying "200" (and possibly even "HTTP status 200 OK") would make it harder to misunderstand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed doc @tkashem !
I think the next step will be to make this doc discoverable by linking this doc from the code that defines these healthchecks in data/data/{aws,gcp} ..

@abhinavdahiya I linked the doc.

* E2: `T+0s`: `/readyz` starts reporting `failure` to signal to the load balancers that a shut down is in progress.
* The apiserver will continue to accept new request(s).
* The apiserver waits for certain amount of time (configurable by `shutdown-delay-duration`) before it stops accepting new request(s).
* E3: `T+70s`: `kube-apiserver` (the http server) stops listening:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elsewhere in the doc you have:

In future we will reduce shutdown-delay-duration to 30s.

I'd rather make this portion of the doc robust to that sort of pivot by using T+shudown-delay-duration here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as the user/dev is concerned, they should treat shutdown-delay-duration to be 30s for the purpose of designing health check probes. So I changed it to T+30s.

* `/healthz` turns red.
* Default TCP health check probe on port `6443` will fail.
* Any new request forwarded to it will fail, most likely with a `connection refused` error or `GOAWAY` for http/2.
* Existing request(s) in-flight are not cut off but are given up to `60s` to complete gracefully.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this 60s also have a config variable name that we can use to guard against future default changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hardcoded in kube-apiserver.

@sttts
Copy link
Contributor

sttts commented May 7, 2020

lgtm

@abhinavdahiya
Copy link
Contributor

Thanks for the detailed doc @tkashem !

I think the next step will be to make this doc discoverable by linking this doc from the code that defines these healthchecks in data/data/{aws,gcp} ..

@tkashem hopefully you saw this.

cybertron added a commit to cybertron/baremetal-runtimecfg that referenced this pull request May 11, 2020
Per [0], the /readyz endpoint is how the api communicates that it
is gracefully shutting down. Once /readyz starts to report failure,
we want to stop sending traffic to that backend. If we wait for
/healthz, it may be too late because once /healthz starts failing
the api is already not accepting connections.

0: openshift/installer#3537
cybertron added a commit to cybertron/machine-config-operator that referenced this pull request May 11, 2020
Per [0], the /readyz endpoint is how the api communicates that it
is gracefully shutting down. Once /readyz starts to report failure,
we want to stop sending traffic to that backend. If we wait for
/healthz, it may be too late because once /healthz starts failing
the api is already not accepting connections.

I also moved the liveness probe for haproxy itself to use a /readyz
endpoint for consistency. This isn't strictly necessary, but I think
it will be less confusing if there aren't multiple health check
endpoints in the config.

0: openshift/installer#3537
@tkashem tkashem force-pushed the kube-apiserver-health-check branch from b8d4bb5 to dcd415c Compare May 11, 2020 19:36
@@ -1,5 +1,6 @@
def GenerateConfig(context):

// Refer to docs/dev/kube-apiserver-health-check.md on how to correctly setup health check probe for kube-apiserver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably not correct comment syntax in python

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, my bad. fixed.

@@ -6,6 +6,7 @@ def GenerateConfig(context):
'group': '$(ref.' + context.properties['infra_id'] + '-master-' + zone + '-instance-group' + '.selfLink)'
})

// Refer to docs/dev/kube-apiserver-health-check.md on how to correctly setup health check probe for kube-apiserver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@abhinavdahiya
Copy link
Contributor

/test e2e-gcp-upi

@tkashem tkashem force-pushed the kube-apiserver-health-check branch from 49cb2af to 3bc71bb Compare May 11, 2020 20:29
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 11, 2020

@tkashem: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-gcp-upi 49cb2af link /test e2e-gcp-upi

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@abhinavdahiya
Copy link
Contributor

/approve
/lgtm

@abhinavdahiya
Copy link
Contributor

Adding valid bug since this is docs update

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 12, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 12, 2020
@abhinavdahiya abhinavdahiya added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. retest-not-required-docs-only labels May 12, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit a1a6300 into openshift:master May 12, 2020
EgorLu pushed a commit to EgorLu/machine-config-operator that referenced this pull request Aug 10, 2020
Per [0], the /readyz endpoint is how the api communicates that it
is gracefully shutting down. Once /readyz starts to report failure,
we want to stop sending traffic to that backend. If we wait for
/healthz, it may be too late because once /healthz starts failing
the api is already not accepting connections.

I also moved the liveness probe for haproxy itself to use a /readyz
endpoint for consistency. This isn't strictly necessary, but I think
it will be less confusing if there aren't multiple health check
endpoints in the config.

0: openshift/installer#3537
(cherry picked from commit 022933c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged. retest-not-required-docs-only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants