Skip to content

[KEP:4827] Structured statusz#134313

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
richabanker:statusz-structured
Oct 30, 2025
Merged

[KEP:4827] Structured statusz#134313
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
richabanker:statusz-structured

Conversation

@richabanker
Copy link
Copy Markdown
Contributor

@richabanker richabanker commented Sep 28, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds an alphav1 structured response for /statusz endpoint

Which issue(s) this PR is related to:

KEP: kubernetes/enhancements#4827

Does this PR introduce a user-facing change?

Introduces a structured and versioned v1alpha1 response for statusz

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

Tested on a kind cluster

Plain/text response returned by default if no Accept header is provided

$ curl -k --cert /etc/kubernetes/pki/apiserver-kubelet-client.crt --key /etc/kubernetes/pki/apiserver-kubelet-client.key https://localhost:6443/statusz

apiserver statusz
Warning: This endpoint is not meant to be machine parseable, has no formatting compatibility guarantees and is for debugging purposes only.

Started= Tue Oct 21 22:51:35 UTC 2025
Up= 0 hr 07 min 13 sec
Go version= go1.25.3
Binary version= 1.35.0-alpha.0.1423+6e7fded83b85b0-dirty
Emulation version= 1.35
Paths= /healthz /livez /metrics /readyz /statusz /version

Structured JSON is returned if correct Accept header is provided

$ curl -k --cert /etc/kubernetes/pki/apiserver-kubelet-client.crt --key /etc/kubernetes/pki/apiserver-kubelet-client.key https://localhost:6443/statusz -H "Accept: application/json;v=v1alpha1;g=config.k8s.io;as=Statusz" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   324  100   324    0     0  35502      0 --:--:-- --:--:-- --:--:-- 36000
{
  "kind": "Statusz",
  "apiVersion": "config.k8s.io/v1alpha1",
  "metadata": {
    "name": "apiserver"
  },
  "startTime": "2025-10-29T00:30:01Z",
  "uptimeSeconds": 856,
  "goVersion": "go1.25.3",
  "binaryVersion": "1.35.0-alpha.0.1595+b288caa2c26536-dirty",
  "emulationVersion": "1.35",
  "paths": [
    "/healthz",
    "/livez",
    "/metrics",
    "/readyz",
    "/statusz",
    "/version"
  ]
}

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 28, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 28, 2025
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Instrumentation Sep 28, 2025
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 28, 2025
@richabanker richabanker force-pushed the statusz-structured branch 3 times, most recently from 23ccc1a to 564ed3f Compare September 28, 2025 02:00
@richabanker richabanker force-pushed the statusz-structured branch 8 times, most recently from fb0c524 to 99f472d Compare October 7, 2025 00:14
@k8s-ci-robot k8s-ci-robot added sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 28, 2025
@richabanker richabanker force-pushed the statusz-structured branch 2 times, most recently from afeccb9 to 5b82b75 Compare October 28, 2025 23:39
@k8s-ci-robot k8s-ci-robot added area/code-generation kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Oct 28, 2025
@k8s-triage-robot
Copy link
Copy Markdown

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@richabanker richabanker force-pushed the statusz-structured branch 4 times, most recently from 862651d to 7e359e2 Compare October 29, 2025 17:05
case "application/json":
if mediaType.Convert == nil || mediaType.Convert.GroupVersion() != schemeGroupVersion {
utilruntime.HandleError(fmt.Errorf("expected statusz group version, got group: %s, version %s", mediaType.Convert.Group, mediaType.Convert.Version))
w.WriteHeader(http.StatusInternalServerError)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's possible to get here... a request that doesn't set these gets a not-acceptable error response, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the same pattern as in discovery but yeah seems redundant. Removed.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Oct 29, 2025

an integration test that turns on the feature and actually hits the /statusz endpoint with the few accept types to exercise success cases and error cases would build confidence all the wiring works like we want

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 30, 2025
@richabanker
Copy link
Copy Markdown
Contributor Author

richabanker commented Oct 30, 2025

an integration test that turns on the feature and actually hits the /statusz endpoint with the few accept types to exercise success cases and error cases would build confidence all the wiring works like we want

Found existing integration tests for apiserver, scheduler and kcm which I have updated to check for both text and json responses. There's still some remaining clean up to do for unit tests in kubelet and kube-proxy (which only validate the text response currently) which I can do in a follow up.

Copy link
Copy Markdown
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple last comments, then lgtm

Comment thread staging/src/k8s.io/apiserver/pkg/server/statusz/api/v1alpha1/doc.go Outdated
Comment thread staging/src/k8s.io/apiserver/pkg/server/statusz/statusz.go
Comment thread staging/src/k8s.io/apiserver/pkg/server/statusz/statusz.go
@liggitt
Copy link
Copy Markdown
Member

liggitt commented Oct 30, 2025

/lgtm
/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: ff8faea7221b6f35b8ec2164778c5126929aa382

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, richabanker

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yongruilin
Copy link
Copy Markdown
Contributor

/lgtm
/retest

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 99981844958d2e43e4171eda0ea667c0721c6cdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/code-generation area/kube-proxy area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

Status: API review completed, 1.35
Archived in project
Archived in project
Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants