Skip to content

Commit 8308aab

Browse files
committed
Add documentation for API server health checks
1 parent 47ae7dd commit 8308aab

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Kubernetes API health endpoints
3+
reviewers:
4+
- logicalhan
5+
content_type: concept
6+
weight: 50
7+
---
8+
9+
<!-- overview -->
10+
The Kubernetes {{< glossary_tooltip term_id="kube-apiserver" text="API server" >}} provides API endpoints to indicate the current status of the API server.
11+
This page describes these API endpoints and explains how you can use them.
12+
13+
<!-- body -->
14+
15+
## API endpoints for health
16+
17+
The Kubernetes API server provides 3 API endpoints (`healthz`, `livez` and `readyz`) to indicate the current status of the API server.
18+
The `healthz` endpoint is deprecated (since Kubernetes v1.16), and you should use the more specific `livez` and `readyz` endpoints instead.
19+
The `livez` endpoint can be used with the `--livez-grace-period` [flag](/docs/reference/command-line-tools-reference/kube-apiserver) to specify the startup duration.
20+
For a graceful shutdown you can specify the `--shutdown-delay-duration` [flag](/docs/reference/command-line-tools-reference/kube-apiserver) with the `/readyz` endpoint.
21+
Machines that check the `health`/`livez`/`readyz` of the API server should rely on the HTTP status code.
22+
A status code `200` indicates the the API server is `healthy`/`live`/`ready`, depending of the called endpoint.
23+
The more verbose options shown below are intended to be used by human operators to debug their cluster or specially the state of the API server.
24+
25+
The following examples will show how you can interact with the health API endpoints.
26+
27+
For all endpoints you can use the `verbose` parameter to print out the checks and their status.
28+
This can be useful for a human operator to debug the current status of the Api server, it is not intended to be consumed by a machine:
29+
30+
```shell
31+
curl -k https://localhost:6443/livez?verbose
32+
```
33+
34+
The output will look like this:
35+
36+
[+]ping ok
37+
[+]log ok
38+
[+]etcd ok
39+
[+]poststarthook/start-kube-apiserver-admission-initializer ok
40+
[+]poststarthook/generic-apiserver-start-informers ok
41+
[+]poststarthook/start-apiextensions-informers ok
42+
[+]poststarthook/start-apiextensions-controllers ok
43+
[+]poststarthook/crd-informer-synced ok
44+
[+]poststarthook/bootstrap-controller ok
45+
[+]poststarthook/rbac/bootstrap-roles ok
46+
[+]poststarthook/scheduling/bootstrap-system-priority-classes ok
47+
[+]poststarthook/start-cluster-authentication-info-controller ok
48+
[+]poststarthook/start-kube-aggregator-informers ok
49+
[+]poststarthook/apiservice-registration-controller ok
50+
[+]poststarthook/apiservice-status-available-controller ok
51+
[+]poststarthook/kube-apiserver-autoregistration ok
52+
[+]autoregister-completion ok
53+
[+]poststarthook/apiservice-openapi-controller ok
54+
healthz check passed
55+
56+
The Kubernetes API server also supports to exclude specific checks.
57+
The query parameters can also be combined like in this example:
58+
59+
```shell
60+
curl -k 'https://localhost:6443/readyz?verbose&exclude=etcd'
61+
```
62+
63+
The output show that the `etcd` check is excluded:
64+
65+
[+]ping ok
66+
[+]log ok
67+
[+]etcd excluded: ok
68+
[+]poststarthook/start-kube-apiserver-admission-initializer ok
69+
[+]poststarthook/generic-apiserver-start-informers ok
70+
[+]poststarthook/start-apiextensions-informers ok
71+
[+]poststarthook/start-apiextensions-controllers ok
72+
[+]poststarthook/crd-informer-synced ok
73+
[+]poststarthook/bootstrap-controller ok
74+
[+]poststarthook/rbac/bootstrap-roles ok
75+
[+]poststarthook/scheduling/bootstrap-system-priority-classes ok
76+
[+]poststarthook/start-cluster-authentication-info-controller ok
77+
[+]poststarthook/start-kube-aggregator-informers ok
78+
[+]poststarthook/apiservice-registration-controller ok
79+
[+]poststarthook/apiservice-status-available-controller ok
80+
[+]poststarthook/kube-apiserver-autoregistration ok
81+
[+]autoregister-completion ok
82+
[+]poststarthook/apiservice-openapi-controller ok
83+
[+]shutdown ok
84+
healthz check passed
85+
86+
Each individual health check exposes an http endpoint and could can be checked individually.
87+
The schema for the individual health checks is `/livez/<healthcheck-name>` where `livez` and `readyz` and be used to indicate if you want to check thee liveness or the readiness of the API server.
88+
The `<healthcheck-name>` path can be discovered using the `verbose` flag from above and take the path between `[+]` and `ok`.
89+
These individual health checks should not be consumed by machines but can be helpful for a human operator to debug a system:
90+
91+
```shell
92+
curl -k https://localhost:6443/livez/etcd
93+
```

0 commit comments

Comments
 (0)