Skip to content

Commit 819a31b

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

File tree

1 file changed

+80
-24
lines changed
  • keps/sig-instrumentation/4827-component-statusz

1 file changed

+80
-24
lines changed

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

Lines changed: 80 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ 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)
3129
- [Response fields](#response-fields)
32-
- [Sample response](#sample-response)
30+
- [Data format: text (default)](#data-format-text-default)
31+
- [Request](#request)
32+
- [Sample response](#sample-response)
33+
- [Data format: JSON (v1)](#data-format-json-v1)
34+
- [Request](#request-1)
35+
- [Sample Response](#sample-response-1)
3336
- [Test Plan](#test-plan)
3437
- [Prerequisite testing updates](#prerequisite-testing-updates)
3538
- [Unit tests](#unit-tests)
@@ -158,15 +161,22 @@ We are proposing to add a new endpoint, /statusz on all core Kubernetes componen
158161

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

161-
3. **Premature Dependency on Unstable Format**
164+
3. **API Stability and Evolution**
162165

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
166+
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.
167+
168+
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.
164169

165170
## Design Details
166171

167172
### Data Format and versioning
168173

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.
174+
The `/statusz` endpoint uses content negotiation via the `Accept` header to serve different response formats. The default response format is `text/plain`, which is intended for human consumption and backward compatibility.
175+
176+
For programmatic access, a structured, versioned JSON response is available. Clients can request the structured format by specifying the appropriate `Accept` header:
177+
`Accept: application/json;v=v1`
178+
179+
If the `Accept` header is omitted or set to `text/plain`, the endpoint will return the default plain text response. This approach allows for a stable, machine-readable API while preserving the simple text-based output.
170180

171181
### Authz and authn
172182

@@ -189,14 +199,6 @@ rules:
189199
190200
### Endpoint Response Format
191201
192-
#### Data format : text
193-
194-
#### Request
195-
* Method: **GET**
196-
* Endpoint: **/statusz**
197-
* Header: `Content-Type: text/plain`
198-
* Body: empty
199-
200202
#### Response fields
201203
* **Start Time**: The exact date and time when the component process was initiated
202204
* **Uptime**: The duration for which the component has been running continuously
@@ -206,7 +208,17 @@ rules:
206208
* **Minimum Compatibility Version**: The minimum Kubernetes API version with which the component is designed to work seamlessly
207209
* **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
208210
209-
#### Sample response
211+
#### Data format: text (default)
212+
213+
This format is the default and is intended for human readability and backward compatibility.
214+
215+
##### Request
216+
* Method: **GET**
217+
* Endpoint: **/statusz**
218+
* Header: `Accept: text/plain` (or no Accept header)
219+
* Body: empty
220+
221+
##### Sample response
210222

211223
```
212224
Started: Fri Sep 6 06:19:51 UTC 2024
@@ -225,6 +237,38 @@ metrics:/metrics
225237
readyz:/readyz
226238
sli metrics:/metrics/slis
227239
```
240+
241+
#### Data format: JSON (v1)
242+
243+
This is the preferred format for programmatic access.
244+
245+
##### Request
246+
* Method: **GET**
247+
* Endpoint: **/statusz**
248+
* Header: `Accept: application/json;v=v1`
249+
* Body: empty
250+
251+
##### Sample Response
252+
253+
```json
254+
{
255+
"apiVersion": "v1",
256+
"startTime": "2024-09-06T06:19:51Z",
257+
"upTime": "30s",
258+
"goVersion": "go1.23.0",
259+
"binaryVersion": "1.31.0-beta.0.981+c6be932655a03b-dirty",
260+
"emulationVersion": "1.31.0-beta.0.981",
261+
"minimumCompatibilityVersion": "1.30.0",
262+
"usefulLinks": {
263+
"configz": "/configz",
264+
"healthz": "/healthz",
265+
"livez": "/livez",
266+
"metrics": "/metrics",
267+
"readyz": "/readyz",
268+
"sli_metrics": "/metrics/slis"
269+
}
270+
}
271+
```
228272
### Test Plan
229273

230274
[x] I/we understand the owners of the involved components may require updates to
@@ -233,34 +277,46 @@ to implement this enhancement.
233277

234278
##### Prerequisite testing updates
235279

280+
N/A
281+
236282
##### Unit tests
237283

238-
- There will addition of new tests in the following packages
239-
- `staging/src/k8s.io/component-base/zpages/statusz`: `2024-10-08` - `100%`
284+
- `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.
240285

241286
##### Integration tests
242287

288+
- 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.
243289

244290
##### e2e tests
245291

246-
- Ensure existence of the /statusz endpoint
292+
- E2E tests will be added to query the `/statusz` endpoint for each core component and validate the following:
293+
- The endpoint is reachable and returns a `200 OK` status.
294+
- Requesting with the `Accept` header for `application/json;v=v1` returns a valid JSON object.
295+
- The JSON response can be successfully unmarshalled.
296+
- Requesting with `text/plain` or no `Accept` header returns the non-empty plain text format.
247297

248298
### Graduation Criteria
249299

250300
#### Alpha
251301

252-
- Feature implemented behind a feature flag
253-
- Feature implemented for apiserver
254-
- Ensure proper tests are in place.
302+
- Feature implemented behind a feature flag (`ComponentStatusz`).
303+
- Feature implemented for apiserver.
304+
- Initial implementation provides a plain text response.
305+
- Basic unit tests are in place.
255306

256307
#### Beta
257308

258-
- Gather feedback from developers
259-
- Feature implemented for other Kubernetes Components
309+
- Feature gate `ComponentStatusz` is enabled by default.
310+
- Structured, versioned JSON response format is implemented.
311+
- Plain text format is maintained for backward compatibility.
312+
- Feature is implemented for all core Kubernetes components (kube-apiserver, kube-controller-manager, kube-scheduler, kubelet, kube-proxy).
313+
- Integration and e2e tests are added for the JSON response format.
314+
- Gather feedback from users and developers on the structured format.
260315

261316
#### GA
262317

263-
- Several cycles of bake-time
318+
- The versioned JSON response is considered stable.
319+
- Several cycles of bake-time to ensure API stability and usefulness.
264320

265321
#### Deprecation
266322

0 commit comments

Comments
 (0)