Skip to content

Commit a960269

Browse files
authored
Merge pull request #53030 from richabanker/zpages
Add blog article about zpages
2 parents d44fd66 + 58efab3 commit a960269

File tree

1 file changed

+218
-0
lines changed

1 file changed

+218
-0
lines changed
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.35: Enhanced Debugging with Versioned z-pages APIs"
4+
draft: true
5+
slug: kubernetes-1-35-structured-zpages
6+
author: >
7+
[Richa Banker](https://github.com/richabanker),
8+
[Han Kang](https://github.com/cncf/memorials/blob/main/han-kang.md)
9+
---
10+
11+
Debugging Kubernetes control plane components can be challenging, especially when you need to quickly understand the runtime state of a component or verify its configuration. With Kubernetes 1.35, we're enhancing the z-pages debugging endpoints with structured, machine-parseable responses that make it easier to build tooling and automate troubleshooting workflows.
12+
13+
## What are z-pages?
14+
15+
z-pages are special debugging endpoints exposed by Kubernetes control plane components. Introduced as an alpha feature in Kubernetes 1.32, these endpoints provide runtime diagnostics for components like `kube-apiserver`, `kube-controller-manager`, `kube-scheduler`, `kubelet` and `kube-proxy`. The name "z-pages" comes from the convention of using `/*z` paths for debugging endpoints.
16+
17+
Currently, Kubernetes supports two primary z-page endpoints:
18+
19+
`/statusz`
20+
: Displays high-level component information including version information, start time, uptime, and available debug paths
21+
22+
`/flagz`
23+
: Shows all command-line arguments and their values used to start the component (with confidential values redacted for security)
24+
25+
These endpoints are valuable for human operators who need to quickly inspect component state, but until now, they only returned plain text output that was difficult to parse programmatically.
26+
27+
## What's new in Kubernetes 1.35?
28+
29+
Kubernetes 1.35 introduces structured, versioned responses for both `/statusz` and `/flagz` endpoints. This enhancement maintains backward compatibility with the existing plain text format while adding support for machine-readable JSON responses.
30+
31+
### Backward compatible design
32+
33+
The new structured responses are opt-in. Without specifying an `Accept` header, the endpoints continue to return the familiar plain text format:
34+
35+
```
36+
$ curl --cert /etc/kubernetes/pki/apiserver-kubelet-client.crt \
37+
--key /etc/kubernetes/pki/apiserver-kubelet-client.key \
38+
--cacert /etc/kubernetes/pki/ca.crt \
39+
https://localhost:6443/statusz
40+
41+
kube-apiserver statusz
42+
Warning: This endpoint is not meant to be machine parseable, has no formatting compatibility guarantees and is for debugging purposes only.
43+
44+
Started: Wed Oct 16 21:03:43 UTC 2024
45+
Up: 0 hr 00 min 16 sec
46+
Go version: go1.23.2
47+
Binary version: 1.35.0-alpha.0.1595
48+
Emulation version: 1.35
49+
Paths: /healthz /livez /metrics /readyz /statusz /version
50+
```
51+
52+
### Structured JSON responses
53+
54+
To receive a structured response, include the appropriate `Accept` header:
55+
56+
```
57+
Accept: application/json;v=v1alpha1;g=config.k8s.io;as=Statusz
58+
```
59+
60+
This returns a versioned JSON response:
61+
62+
```json
63+
{
64+
"kind": "Statusz",
65+
"apiVersion": "config.k8s.io/v1alpha1",
66+
"metadata": {
67+
"name": "kube-apiserver"
68+
},
69+
"startTime": "2025-10-29T00:30:01Z",
70+
"uptimeSeconds": 856,
71+
"goVersion": "go1.23.2",
72+
"binaryVersion": "1.35.0",
73+
"emulationVersion": "1.35",
74+
"paths": [
75+
"/healthz",
76+
"/livez",
77+
"/metrics",
78+
"/readyz",
79+
"/statusz",
80+
"/version"
81+
]
82+
}
83+
```
84+
85+
Similarly, `/flagz` supports structured responses with the header:
86+
87+
```
88+
Accept: application/json;v=v1alpha1;g=config.k8s.io;as=Flagz
89+
```
90+
91+
Example response:
92+
93+
```json
94+
{
95+
"kind": "Flagz",
96+
"apiVersion": "config.k8s.io/v1alpha1",
97+
"metadata": {
98+
"name": "kube-apiserver"
99+
},
100+
"flags": {
101+
"advertise-address": "192.168.8.4",
102+
"allow-privileged": "true",
103+
"authorization-mode": "[Node,RBAC]",
104+
"enable-priority-and-fairness": "true",
105+
"profiling": "true"
106+
}
107+
}
108+
```
109+
110+
## Why structured responses matter
111+
112+
The addition of structured responses opens up several new possibilities:
113+
114+
### 1. **Automated health checks and monitoring**
115+
116+
Instead of parsing plain text, monitoring tools can now easily extract specific fields. For example, you can programmatically check if a component has been running with an unexpected emulated version or verify that critical flags are set correctly.
117+
118+
### 2. **Better debugging tools**
119+
120+
Developers can build sophisticated debugging tools that compare configurations across multiple components or track configuration drift over time. The structured format makes it trivial to `diff` configurations or validate that components are running with expected settings.
121+
122+
### 3. **API versioning and stability**
123+
124+
By introducing versioned APIs (starting with `v1alpha1`), we provide a clear path to stability. As the feature matures, we'll introduce `v1beta1` and eventually `v1`, giving you confidence that your tooling won't break with future Kubernetes releases.
125+
126+
## How to use structured z-pages
127+
128+
### Prerequisites
129+
130+
Both endpoints require feature gates to be enabled:
131+
132+
- `/statusz`: Enable the `ComponentStatusz` feature gate
133+
- `/flagz`: Enable the `ComponentFlagz` feature gate
134+
135+
### Example: Getting structured responses
136+
137+
Here's an example using `curl` to retrieve structured JSON responses from the kube-apiserver:
138+
139+
```bash
140+
# Get structured statusz response
141+
curl \
142+
--cert /etc/kubernetes/pki/apiserver-kubelet-client.crt \
143+
--key /etc/kubernetes/pki/apiserver-kubelet-client.key \
144+
--cacert /etc/kubernetes/pki/ca.crt \
145+
-H "Accept: application/json;v=v1alpha1;g=config.k8s.io;as=Statusz" \
146+
https://localhost:6443/statusz | jq .
147+
148+
# Get structured flagz response
149+
curl \
150+
--cert /etc/kubernetes/pki/apiserver-kubelet-client.crt \
151+
--key /etc/kubernetes/pki/apiserver-kubelet-client.key \
152+
--cacert /etc/kubernetes/pki/ca.crt \
153+
-H "Accept: application/json;v=v1alpha1;g=config.k8s.io;as=Flagz" \
154+
https://localhost:6443/flagz | jq .
155+
```
156+
157+
{{< note >}}
158+
The examples above use client certificate authentication and verify the server's certificate using `--cacert`.
159+
If you need to bypass certificate verification in a test environment, you can use `--insecure` (or `-k`),
160+
but this should never be done in production as it makes you vulnerable to man-in-the-middle attacks.
161+
{{< /note >}}
162+
163+
## Important considerations
164+
165+
### Alpha feature status
166+
167+
The structured z-page responses are an **alpha** feature in Kubernetes 1.35. This means:
168+
169+
- The API format may change in future releases
170+
- These endpoints are intended for debugging, not production automation
171+
- You should avoid relying on them for critical monitoring workflows until they reach beta or stable status
172+
173+
### Security and access control
174+
175+
z-pages expose internal component information and require proper access controls. Here are the key security considerations:
176+
177+
**Authorization**: Access to z-page endpoints is restricted to members of the `system:monitoring` group, which follows the same authorization model as other debugging endpoints like `/healthz`, `/livez`, and `/readyz`. This ensures that only authorized users and service accounts can access debugging information. If your cluster uses RBAC, you can manage access by granting appropriate permissions to this group.
178+
179+
**Authentication**: The authentication requirements for these endpoints depend on your cluster's configuration. Unless anonymous authentication is enabled for your cluster, you typically need to use authentication mechanisms (such as client certificates) to access these endpoints.
180+
181+
**Information disclosure**: These endpoints reveal configuration details about your cluster components, including:
182+
- Component versions and build information
183+
- All command-line arguments and their values (with confidential values redacted)
184+
- Available debug endpoints
185+
186+
Only grant access to trusted operators and debugging tools. Avoid exposing these endpoints to unauthorized users or automated systems that don't require this level of access.
187+
188+
### Future evolution
189+
190+
As the feature matures, we (Kubernetes SIG Instrumentation) expect to:
191+
192+
- Introduce `v1beta1` and eventually `v1` versions of the API
193+
- Gather community feedback on the response schema
194+
- Potentially add additional z-page endpoints based on user needs
195+
196+
## Try it out
197+
198+
We encourage you to experiment with structured z-pages in a test environment:
199+
200+
1. Enable the `ComponentStatusz` and `ComponentFlagz` feature gates on your control plane components
201+
2. Try querying the endpoints with both plain text and structured formats
202+
3. Build a simple tool or script that uses the structured data
203+
4. Share your feedback with the community
204+
205+
## Learn more
206+
207+
- [z-pages documentation](/docs/reference/instrumentation/zpages/)
208+
- [KEP-4827: Component Statusz](https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/4827-component-statusz/README.md)
209+
- [KEP-4828: Component Flagz](https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/4828-component-flagz/README.md)
210+
- Join the discussion in the [#sig-instrumentation](https://kubernetes.slack.com/archives/C20HH14P7) channel on Kubernetes Slack
211+
212+
## Get involved
213+
214+
We'd love to hear your feedback! The structured z-pages feature is designed to make Kubernetes easier to debug and monitor. Whether you're building internal tooling, contributing to open source projects, or just exploring the feature, your input helps shape the future of Kubernetes observability.
215+
216+
If you have questions, suggestions, or run into issues, please reach out to SIG Instrumentation. You can find us on Slack or at our regular [community meetings](https://github.com/kubernetes/community/tree/master/sig-instrumentation).
217+
218+
Happy debugging!

0 commit comments

Comments
 (0)