Skip to content

Commit 4979cb1

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

File tree

1 file changed

+140
-30
lines changed
  • keps/sig-instrumentation/4827-component-statusz

1 file changed

+140
-30
lines changed

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

Lines changed: 140 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ 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+
- [Data format: text](#data-format-text)
30+
- [Request](#request)
31+
- [Sample response](#sample-response)
32+
- [Data format: JSON (v1alpha1)](#data-format-json-v1alpha1)
33+
- [Request](#request-1)
34+
- [Response Body: <code>ComponentStatus</code> object](#response-body-componentstatus-object)
35+
- [Sample Response](#sample-response-1)
36+
- [API Versioning and Deprecation Policy](#api-versioning-and-deprecation-policy)
3337
- [Test Plan](#test-plan)
3438
- [Prerequisite testing updates](#prerequisite-testing-updates)
3539
- [Unit tests](#unit-tests)
@@ -158,15 +162,32 @@ We are proposing to add a new endpoint, /statusz on all core Kubernetes componen
158162

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

161-
3. **Premature Dependency on Unstable Format**
165+
3. **API Stability and Evolution**
162166

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
167+
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.
168+
169+
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.
164170

165171
## Design Details
166172

167173
### Data Format and versioning
168174

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.
175+
The `/statusz` endpoint defaults to a `text/plain` response format, which is intended for human consumption and should not be parsed by automated tools.
176+
177+
Beginning in Beta, a structured, versioned JSON format is available for programmatic access. This will follow the standard Kubernetes content negotiation mechanism, requiring a group, version, and kind.
178+
179+
- **Group**: `component.k8s.io`
180+
- **Version**: `v1alpha1` (initial version, subject to change)
181+
- **Kind**: `ComponentStatus`
182+
183+
To receive the structured JSON response, a client **must** explicitly request it using an `Accept` header specifying these parameters. For example:
184+
185+
```
186+
GET /statusz
187+
Accept: application/json;as=ComponentStatus;v=v1alpha1;g=component.k8s.io
188+
```
189+
190+
This negotiation mechanism ensures clients are explicit about the exact API they want, preventing accidental dependencies on unstable or incorrect formats. If a client requests `application/json` without the required parameters, the server will respond with a `406 Not Acceptable` error.
170191

171192
### Authz and authn
172193

@@ -189,24 +210,19 @@ rules:
189210
190211
### Endpoint Response Format
191212
192-
#### Data format : text
213+
The `/statusz` endpoint supports both plain text and structured JSON formats. The default format is `text/plain`.
214+
215+
#### Data format: text
216+
217+
This format is the default and is intended for human readability.
193218

194-
#### Request
195-
* Method: **GET**
219+
##### Request
220+
* Method: **GET**
196221
* Endpoint: **/statusz**
197-
* Header: `Content-Type: text/plain`
222+
* Header: `Accept: text/plain` (or no Accept header)
198223
* Body: empty
199224

200-
#### Response fields
201-
* **Start Time**: The exact date and time when the component process was initiated
202-
* **Uptime**: The duration for which the component has been running continuously
203-
* **Go Version**: The specific version of the Go programming language used to build the component's binary
204-
* **Binary Version**: The version of the component's binary, helpful for compatibility checks and troubleshooting
205-
* **Emulation Version**: The Kubernetes API version which this component is emulating as
206-
* **Minimum Compatibility Version**: The minimum Kubernetes API version with which the component is designed to work seamlessly
207-
* **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
208-
209-
#### Sample response
225+
##### Sample response
210226

211227
```
212228
Started: Fri Sep 6 06:19:51 UTC 2024
@@ -225,6 +241,88 @@ metrics:/metrics
225241
readyz:/readyz
226242
sli metrics:/metrics/slis
227243
```
244+
245+
#### Data format: JSON (v1alpha1)
246+
247+
This format is available starting in Beta for programmatic access and must be explicitly requested. It is considered an alpha-level format and is subject to change.
248+
249+
##### Request
250+
* Method: **GET**
251+
* Endpoint: **/statusz**
252+
* Header: `Accept: application/json;as=ComponentStatus;v=v1alpha1;g=component.k8s.io`
253+
* Body: empty
254+
255+
##### Response Body: `ComponentStatus` object
256+
257+
The response is a `ComponentStatus` object with the following structure:
258+
259+
```json
260+
{
261+
"kind": "ComponentStatus",
262+
"apiVersion": "component.k8s.io/v1alpha1",
263+
"metadata": {
264+
"name": "<component-name>",
265+
"creationTimestamp": "<start-time>"
266+
},
267+
"startTime": "<start-time>",
268+
"upTime": "<uptime-duration>",
269+
"buildInformation": {
270+
"goVersion": "<go-version>",
271+
"binaryVersion": "<binary-version>",
272+
"emulationVersion": "<emulation-version>",
273+
"minimumCompatibilityVersion": "<min-compatibility-version>"
274+
},
275+
"usefulLinks": {
276+
"configz": "/configz",
277+
"healthz": "/healthz",
278+
"livez": "/livez",
279+
"metrics": "/metrics",
280+
"readyz": "/readyz",
281+
"sli_metrics": "/metrics/slis"
282+
}
283+
}
284+
```
285+
286+
##### Sample Response
287+
288+
```json
289+
{
290+
"kind": "ComponentStatus",
291+
"apiVersion": "component.k8s.io/v1alpha1",
292+
"metadata": {
293+
"name": "kube-apiserver",
294+
"creationTimestamp": "2024-09-06T06:19:51Z"
295+
},
296+
"startTime": "2024-09-06T06:19:51Z",
297+
"upTime": "30s",
298+
"buildInformation": {
299+
"goVersion": "go1.23.0",
300+
"binaryVersion": "1.31.0-beta.0.981+c6be932655a03b-dirty",
301+
"emulationVersion": "1.31.0-beta.0.981",
302+
"minimumCompatibilityVersion": "1.30.0"
303+
},
304+
"usefulLinks": {
305+
"configz": "/configz",
306+
"healthz": "/healthz",
307+
"livez": "/livez",
308+
"metrics": "/metrics",
309+
"readyz": "/readyz",
310+
"sli_metrics": "/metrics/slis"
311+
}
312+
}
313+
```
314+
### API Versioning and Deprecation Policy
315+
316+
The versioned `/statusz` endpoint will follow a deprecation policy to ensure a predictable lifecycle for consumers as the API evolves.
317+
318+
The deprecation policy for a given API version (e.g., `v1`) is as follows:
319+
- 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.
320+
321+
The deprecation process will be as follows:
322+
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.
323+
2. **Deprecation Window**: The deprecated API version will be supported for the duration of the deprecation window (at least 12 months or 3 releases).
324+
3. **Removal**: After the deprecation window has passed, the deprecated API version may be removed in a future Kubernetes release.
325+
228326
### Test Plan
229327

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

234332
##### Prerequisite testing updates
235333

334+
N/A
335+
236336
##### Unit tests
237337

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

241340
##### Integration tests
242341

342+
- 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.
243343

244344
##### e2e tests
245345

246-
- Ensure existence of the /statusz endpoint
346+
- E2E tests will be added to query the `/statusz` endpoint for each core component and validate the following:
347+
- The endpoint is reachable and returns a `200 OK` status.
348+
- Requesting with the `Accept` header for `application/json;as=ComponentStatus;v=v1alpha1;g=component.k8s.io` returns a valid `ComponentStatus` JSON object.
349+
- The JSON response can be successfully unmarshalled into the `ComponentStatus` struct.
350+
- Requesting with `text/plain` or no `Accept` header returns the non-empty plain text format.
247351

248352
### Graduation Criteria
249353

250354
#### Alpha
251355

252-
- Feature implemented behind a feature flag
253-
- Feature implemented for apiserver
254-
- Ensure proper tests are in place.
356+
- Feature implemented behind a feature flag (`ComponentStatusz`), disabled by default.
357+
- Feature implemented for at least one component (e.g., kube-apiserver).
358+
- The endpoint provides a `text/plain` response only.
359+
- Unit and integration tests are in place for the plain text format.
255360

256361
#### Beta
257362

258-
- Gather feedback from developers
259-
- Feature implemented for other Kubernetes Components
363+
- Feature gate `ComponentStatusz` is enabled by default.
364+
- A structured JSON response (`component.k8s.io/v1alpha1`) is introduced for feedback.
365+
- The `v1alpha1` JSON format is explicitly marked as alpha-quality and subject to change.
366+
- Feature is implemented for all core Kubernetes components (kube-apiserver, kube-controller-manager, kube-scheduler, kubelet, kube-proxy).
367+
- E2E tests are added for both plain text and the new JSON response format.
368+
- Gather feedback from users and developers on the structured format.
260369

261370
#### GA
262371

263-
- Several cycles of bake-time
372+
- The JSON response API is promoted to `component.k8s.io/v1` and is considered stable after bake-in.
373+
- Conformance tests are in place for the endpoint.
264374

265375
#### Deprecation
266376

0 commit comments

Comments
 (0)