Skip to content

Commit d433b09

Browse files
committed
KEP-4827: Update Beta criteria to include versioned JSON response format
1 parent 5263b73 commit d433b09

File tree

1 file changed

+144
-38
lines changed
  • keps/sig-instrumentation/4827-component-statusz

1 file changed

+144
-38
lines changed

keps/sig-instrumentation/4827-component-statusz/README.md

Lines changed: 144 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ tags, and then generate with `hack/update-toc.sh`.
2626
- [Data Format and versioning](#data-format-and-versioning)
2727
- [Authz and authn](#authz-and-authn)
2828
- [Endpoint Response Format](#endpoint-response-format)
29-
- [Data format : text](#data-format--text)
30-
- [Request](#request)
31-
- [Response fields](#response-fields)
32-
- [Sample response](#sample-response)
29+
- [Response Fields](#response-fields)
30+
- [Data format: JSON (v1)](#data-format-json-v1)
31+
- [Request](#request)
32+
- [Response Body](#response-body)
33+
- [Sample Response](#sample-response)
34+
- [Data format: text](#data-format-text)
35+
- [Request](#request-1)
36+
- [Sample response](#sample-response-1)
37+
- [API Versioning and Deprecation Policy](#api-versioning-and-deprecation-policy)
3338
- [Test Plan](#test-plan)
3439
- [Prerequisite testing updates](#prerequisite-testing-updates)
3540
- [Unit tests](#unit-tests)
@@ -158,15 +163,26 @@ We are proposing to add a new endpoint, /statusz on all core Kubernetes componen
158163

159164
We will prioritize inclusion of only essential diagnostic and monitoring data that aligns with the intended purpose of the z-page.
160165

161-
3. **Premature Dependency on Unstable Format**
166+
3. **API Stability and Evolution**
162167

163-
The alpha release will explicitly support plain text format only, making it clear that the output is not intended for parsing or automated monitoring. The feature will be secured behind a feature gate that is disabled by default, ensuring users opt-in consciously. Also, the endpoint will support specifying a version as a query parameter to facilitate future transitions to structured schema changes without breaking existing integrations, once the usage patterns and requirements are better understood
168+
The alpha release will explicitly support plain text format only, making it clear that the output is not intended for parsing or automated monitoring. The feature will be secured behind a feature gate that is disabled by default, ensuring users opt-in consciously.
169+
170+
For Beta, to provide a stable contract for consumers, we are introducing a versioned JSON response available via content negotiation (`Accept: application/json;v=v1`). The plain text format remains the default for human consumption and backward compatibility.
164171

165172
## Design Details
166173

167174
### Data Format and versioning
168175

169-
Initially, the statusz page will exclusively support a plain text format for responses. In future, when we have established a structured schema for the response, we can support specifying a version param, like /statusz?version=2, to ensure future compatibility. Through this, we can evolve the endpoint and introduce changes to the response schema without impacting clients relying on previous versions, ensuring backward compatibility.
176+
The `/statusz` endpoint will provide a structured, versioned response by default to ensure stability and a clear contract for consumers. The initial version will be `v1`.
177+
178+
The default response format will be `application/json`. Clients can explicitly request the plain text format for human readability by sending an `Accept: text/plain` header.
179+
180+
Clients can request a specific version and format using the `Accept` header, following standard Kubernetes API content negotiation practices. For example:
181+
182+
- **Default (JSON):** `GET /statusz` or `GET /statusz` with `Accept: application/json;v=v1`
183+
- **Plain Text:** `GET /statusz` with `Accept: text/plain`
184+
185+
This approach allows us to evolve the API in the future by introducing new versions (e.g., `v2`, `v3`) without breaking existing clients.
170186

171187
### Authz and authn
172188

@@ -189,15 +205,13 @@ rules:
189205
190206
### Endpoint Response Format
191207
192-
#### Data format : text
208+
The `/statusz` endpoint supports both structured JSON and plain text formats, with JSON being the default.
193209

194-
#### Request
195-
* Method: **GET**
196-
* Endpoint: **/statusz**
197-
* Header: `Content-Type: text/plain`
198-
* Body: empty
210+
#### Response Fields
211+
The following fields are exposed in the response:
199212

200-
#### Response fields
213+
* **apiVersion**: The version of the response schema (JSON only).
214+
* **componentName**: The name of the Kubernetes component.
201215
* **Start Time**: The exact date and time when the component process was initiated
202216
* **Uptime**: The duration for which the component has been running continuously
203217
* **Go Version**: The specific version of the Go programming language used to build the component's binary
@@ -206,25 +220,105 @@ rules:
206220
* **Minimum Compatibility Version**: The minimum Kubernetes API version with which the component is designed to work seamlessly
207221
* **Useful Links**: Relative URLs to other essential endpoints, such as /healthz, /livez, /readyz, and /metrics, for deeper insights into the component's health, readiness, and performance metrics
208222

209-
#### Sample response
223+
#### Data format: JSON (v1)
224+
225+
This is the default and preferred format for programmatic access.
226+
227+
##### Request
228+
* Method: **GET**
229+
* Endpoint: **/statusz**
230+
* Header: `Accept: application/json;v=v1` (or no Accept header)
231+
* Body: empty
232+
233+
##### Response Body
234+
235+
The response is a JSON object with the following structure:
236+
237+
```json
238+
{
239+
"apiVersion": "v1",
240+
"componentName": "<component-name>",
241+
"startTime": "<start-time>",
242+
"upTime": "<uptime-duration>",
243+
"goVersion": "<go-version>",
244+
"binaryVersion": "<binary-version>",
245+
"emulationVersion": "<emulation-version>",
246+
"minimumCompatibilityVersion": "<min-compatibility-version>",
247+
"paths": [
248+
"/configz",
249+
"/healthz",
250+
"/livez",
251+
"/metrics",
252+
"/readyz",
253+
"/metrics/slis"
254+
]
255+
}
256+
```
257+
258+
##### Sample Response
259+
260+
```json
261+
{
262+
"apiVersion": "v1",
263+
"componentName": "kube-apiserver",
264+
"startTime": "2024-09-06T06:19:51Z",
265+
"upTime": "30s",
266+
"goVersion": "go1.23.0",
267+
"binaryVersion": "1.31.0-beta.0.981+c6be932655a03b-dirty",
268+
"emulationVersion": "1.31.0-beta.0.981",
269+
"minimumCompatibilityVersion": "1.30.0",
270+
"paths": [
271+
"/configz",
272+
"/healthz",
273+
"/livez",
274+
"/metrics",
275+
"/readyz",
276+
"/metrics/slis"
277+
]
278+
}
279+
```
280+
281+
#### Data format: text
282+
283+
This format is available for human readability.
284+
285+
##### Request
286+
* Method: **GET**
287+
* Endpoint: **/statusz**
288+
* Header: `Accept: text/plain`
289+
* Body: empty
290+
291+
##### Sample response
210292

211293
```
212-
Started: Fri Sep 6 06:19:51 UTC 2024
213-
Up: 0 hr 00 min 30 sec
214-
Go version: go1.23.0
215-
Binary version: 1.31.0-beta.0.981&#43;c6be932655a03b-dirty
216-
Emulation version: 1.31.0-beta.0.981
217-
Minimum Compatibility version: 1.30.0
218-
219-
List of useful endpoints
294+
Start Time: Fri Sep 6 06:19:51 UTC 2024
295+
Uptime: 0 hr 00 min 30 sec
296+
Go Version: go1.23.0
297+
Binary Version: 1.31.0-beta.0.981&#43;c6be932655a03b-dirty
298+
Emulation Version: 1.31.0-beta.0.981
299+
Minimum Compatibility Version: 1.30.0
300+
301+
Available Paths
220302
--------------
221-
configz:/configz
222-
healthz:/healthz
223-
livez:/livez
224-
metrics:/metrics
225-
readyz:/readyz
226-
sli metrics:/metrics/slis
303+
configz: /configz
304+
healthz: /healthz
305+
livez: /livez
306+
metrics: /metrics
307+
readyz: /readyz
308+
slis: /metrics/slis
227309
```
310+
### API Versioning and Deprecation Policy
311+
312+
The versioned `/statusz` endpoint will follow a deprecation policy to ensure a predictable lifecycle for consumers as the API evolves.
313+
314+
The deprecation policy for a given API version (e.g., `v1`) is as follows:
315+
- A deprecated API version must continue to be served for no less than **12 months or 3 releases** (whichever is longer) after the deprecation is announced.
316+
317+
The deprecation process will be as follows:
318+
1. **Announce Deprecation**: When a new API version is introduced (e.g., `v2`), the older version (e.g., `v1`) will be marked as deprecated. This will be communicated in the official release notes, and requests to the deprecated API version will return a `Warning` header.
319+
2. **Deprecation Window**: The deprecated API version will be supported for the duration of the deprecation window (at least 12 months or 3 releases).
320+
3. **Removal**: After the deprecation window has passed, the deprecated API version may be removed in a future Kubernetes release.
321+
228322
### Test Plan
229323
230324
[x] I/we understand the owners of the involved components may require updates to
@@ -233,34 +327,46 @@ to implement this enhancement.
233327
234328
##### Prerequisite testing updates
235329
330+
N/A
331+
236332
##### Unit tests
237333
238-
- There will addition of new tests in the following packages
239-
- `staging/src/k8s.io/component-base/zpages/statusz`: `2024-10-08` - `100%`
334+
- `staging/src/k8s.io/component-base/zpages/statusz`: Unit tests will be added to cover both the plain text and structured JSON output, including serialization and content negotiation logic.
240335
241336
##### Integration tests
242337
338+
- Integration tests will be added for each component to verify that the `/statusz` endpoint is correctly registered and serves both `text/plain` and the versioned `application/json` content types.
243339
244340
##### e2e tests
245341
246-
- Ensure existence of the /statusz endpoint
342+
- E2E tests will be added to query the `/statusz` endpoint for each core component and validate the following:
343+
- The endpoint is reachable and returns a `200 OK` status.
344+
- Requesting with the `Accept` header for `application/json;v=v1` returns a valid JSON object.
345+
- The JSON response can be successfully unmarshalled.
346+
- Requesting with `text/plain` or no `Accept` header returns the non-empty plain text format.
247347
248348
### Graduation Criteria
249349
250350
#### Alpha
251351
252-
- Feature implemented behind a feature flag
253-
- Feature implemented for apiserver
254-
- Ensure proper tests are in place.
352+
- Feature implemented behind a feature flag (`ComponentStatusz`).
353+
- Feature implemented for apiserver.
354+
- Initial implementation provides a plain text response.
355+
- Basic unit tests are in place.
255356
256357
#### Beta
257358
258-
- Gather feedback from developers
259-
- Feature implemented for other Kubernetes Components
359+
- Feature gate `ComponentStatusz` is enabled by default.
360+
- Structured, versioned JSON response format is implemented.
361+
- Plain text format is maintained for backward compatibility.
362+
- Feature is implemented for all core Kubernetes components (kube-apiserver, kube-controller-manager, kube-scheduler, kubelet, kube-proxy).
363+
- Integration and e2e tests are added for the JSON response format.
364+
- Gather feedback from users and developers on the structured format.
260365
261366
#### GA
262367
263-
- Several cycles of bake-time
368+
- The versioned JSON response is considered stable.
369+
- Several cycles of bake-time to ensure API stability and usefulness.
264370
265371
#### Deprecation
266372

0 commit comments

Comments
 (0)