Kubernetes z-pages
Kubernetes v1.32 [alpha]
Kubernetes 的核心组件可以暴露一系列 z-endpoints,以便用户更轻松地调试他们的集群及其组件。 这些端点仅用于人工检查,以获取组件二进制文件的实时调试信息。请不要自动抓取这些端点返回的数据; 在 Kubernetes 1.35 中,这些是 Alpha 特性,响应格式可能会在未来版本中发生变化。
z-pages
Kubernetes v1.35 允许你启用 z-pages 来帮助排查其核心控制平面组件的问题。 这些特殊的调试端点提供与正在运行的组件有关的内部信息。对于 Kubernetes 1.35, 这些组件提供以下端点(当启用 z-pages 后):
statusz
使用 ComponentStatusz
特性门控启用后,
/statusz 端点显示有关组件的高级信息,例如其 Kubernetes 版本、仿真版本、启动时间等。
来自 API 服务器的 /statusz 纯文本响应类似于:
kube-apiserver statusz
Warning: This endpoint is not meant to be machine parseable, has no formatting compatibility guarantees and is for debugging purposes only.
Started: Wed Oct 16 21:03:43 UTC 2024
Up: 0 hr 00 min 16 sec
Go version: go1.23.2
Binary version: 1.32.0-alpha.0.1484+5eeac4f21a491b-dirty
Emulation version: 1.32.0-alpha.0.1484
Paths: /healthz /livez /metrics /readyz /statusz /version
statusz(结构化的)
Kubernetes v1.32 [alpha](默认禁用)从 Kubernetes v1.35 开始,/statusz 端点支持结构化的、版本化的响应格式,
前提是请求时使用了正确的 Accept 标头。
如果没有 Accept 标头,则该端点默认返回纯文本响应格式。
如需获取结构化回复,请使用:
Accept: application/json;v=v1alpha1;g=config.k8s.io;as=Statusz
说明:
如果你请求 application/json 时未指定所有必需参数(g、v 和 as),
服务器将响应 406 Not Acceptable。
结构化响应示例:
{
"kind": "Statusz",
"apiVersion": "config.k8s.io/v1alpha1",
"metadata": {
"name": "kube-apiserver"
},
"startTime": "2025-10-29T00:30:01Z",
"uptimeSeconds": 856,
"goVersion": "go1.23.2",
"binaryVersion": "1.35.0",
"emulationVersion": "1.35",
"paths": [
"/healthz",
"/livez",
"/metrics",
"/readyz",
"/statusz",
"/version"
]
}
结构化 /statusz 响应的 config.k8s.io/v1alpha1 模式如下:
// Statusz is the config.k8s.io/v1alpha1 schema for the /statusz endpoint.
type Statusz struct {
// Kind is "Statusz".
Kind string `json:"kind"`
// APIVersion is the version of the object, e.g., "config.k8s.io/v1alpha1".
APIVersion string `json:"apiVersion"`
// Standard object's metadata.
// +optional
Metadata metav1.ObjectMeta `json:"metadata,omitempty"`
// StartTime is the time the component process was initiated.
StartTime metav1.Time `json:"startTime"`
// UptimeSeconds is the duration in seconds for which the component has been running continuously.
UptimeSeconds int64 `json:"uptimeSeconds"`
// GoVersion is the version of the Go programming language used to build the binary.
// The format is not guaranteed to be consistent across different Go builds.
// +optional
GoVersion string `json:"goVersion,omitempty"`
// BinaryVersion is the version of the component's binary.
// The format is not guaranteed to be semantic versioning and may be an arbitrary string.
BinaryVersion string `json:"binaryVersion"`
// EmulationVersion is the Kubernetes API version which this component is emulating.
// if present, formatted as "<major>.<minor>"
// +optional
EmulationVersion string `json:"emulationVersion,omitempty"`
// MinimumCompatibilityVersion is the minimum Kubernetes API version with which the component is designed to work.
// if present, formatted as "<major>.<minor>"
// +optional
MinimumCompatibilityVersion string `json:"minimumCompatibilityVersion,omitempty"`
// Paths contains relative URLs to other essential read-only endpoints for debugging and troubleshooting.
// +optional
Paths []string `json:"paths,omitempty"`
}
flagz
使用 ComponentFlagz
特性门控启用后,
/flagz 端点为你显示用于启动某组件的命令行参数。
API 服务器的 /flagz 纯文本响应看起来类似于:
kube-apiserver flags
Warning: This endpoint is not meant to be machine parseable, has no formatting compatibility guarantees and is for debugging purposes only.
advertise-address=192.168.8.2
contention-profiling=false
enable-priority-and-fairness=true
profiling=true
authorization-mode=[Node,RBAC]
authorization-webhook-cache-authorized-ttl=5m0s
authorization-webhook-cache-unauthorized-ttl=30s
authorization-webhook-version=v1beta1
default-watch-cache-size=100
flagz (structured)
Kubernetes v1.32 [alpha](默认禁用)从 Kubernetes v1.35 开始,/flagz 端点支持结构化、版本化的响应格式,
前提是请求时使用了正确的 Accept 标头。
如果没有 Accept 标头,则该端点默认返回纯文本响应格式。
要请求结构化响应,请使用:
Accept: application/json;v=v1alpha1;g=config.k8s.io;as=Flagz
说明:
如果你请求 application/json 时未指定所有必需参数(g、v 和 as),
服务器将响应 406 Not Acceptable。
Example structured response:
{
"kind": "Flagz",
"apiVersion": "config.k8s.io/v1alpha1",
"metadata": {
"name": "kube-apiserver"
},
"flags": {
"advertise-address": "192.168.8.4",
"allow-privileged": "true",
"anonymous-auth": "true",
"authorization-mode": "[Node,RBAC]",
"enable-priority-and-fairness": "true",
"profiling": "true",
"default-watch-cache-size": "100"
}
}
The config.k8s.io/v1alpha1 schema for the structured /flagz response is as follows:
// Flagz is the config.k8s.io/v1alpha1 schema for the /flagz endpoint.
type Flagz struct {
// Kind is "Flagz".
Kind string `json:"kind"`
// APIVersion is the version of the object, e.g., "config.k8s.io/v1alpha1".
APIVersion string `json:"apiVersion"`
// Standard object's metadata.
// +optional
Metadata metav1.ObjectMeta `json:"metadata,omitempty"`
// Flags contains the command-line flags and their values.
// The keys are the flag names and the values are the flag values,
// possibly with confidential values redacted.
// +optional
Flags map[string]string `json:"flags,omitempty"`
}
说明:
/statusz 和 /flagz 的结构化响应在 v1.35 版本中仍处于 Alpha 阶段,未来版本可能会有所更改。
它们旨在为调试和自省工具提供机器可解析的输出。
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.