Skip to content

Commit 8aebf6d

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

File tree

1 file changed

+74
-21
lines changed
  • keps/sig-instrumentation/4827-component-statusz

1 file changed

+74
-21
lines changed

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

Lines changed: 74 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,22 @@ We are proposing to add a new endpoint, /statusz on all core Kubernetes componen
158158

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

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

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
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.
164+
165+
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.
164166

165167
## Design Details
166168

167169
### Data Format and versioning
168170

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.
171+
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.
172+
173+
For programmatic access, a structured, versioned JSON response is available. Clients can request the structured format by specifying the appropriate `Accept` header:
174+
`Accept: application/json;v=v1`
175+
176+
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.
170177

171178
### Authz and authn
172179

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

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

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

234275
##### Prerequisite testing updates
235276

277+
N/A
278+
236279
##### Unit tests
237280

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

241283
##### Integration tests
242284

285+
- 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.
243286

244287
##### e2e tests
245288

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

248295
### Graduation Criteria
249296

250297
#### Alpha
251298

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

256304
#### Beta
257305

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

261313
#### GA
262314

263-
- Several cycles of bake-time
315+
- The versioned JSON response is considered stable.
316+
- Several cycles of bake-time to ensure API stability and usefulness.
264317

265318
#### Deprecation
266319

0 commit comments

Comments
 (0)