Skip to content

feat: run HTTP server standalone without Kubernetes - #1333

Open
tobiasgiese wants to merge 1 commit into
kubernetes:masterfrom
tobiasgiese:run-http-server-standalone
Open

feat: run HTTP server standalone without Kubernetes#1333
tobiasgiese wants to merge 1 commit into
kubernetes:masterfrom
tobiasgiese:run-http-server-standalone

Conversation

@tobiasgiese

Copy link
Copy Markdown
Member

fixes #1332

Extract /healthz, /conditions and /debug/pprof into a new httpexporter package so those endpoints are available when --enable-k8s-exporter=false. Previously the HTTP server was started only inside the k8s exporter, making it unavailable in non-Kubernetes environments. The new httpexporter tracks conditions in-memory via ExportProblems and starts on --port regardless of whether the Kubernetes API server is reachable.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 3, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tobiasgiese
Once this PR has been reviewed and has the lgtm label, please assign sergeykanzhelev for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@tobiasgiese

tobiasgiese commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

With a local built image I can see

❯ docker run --rm --name npd --privileged -v /dev/kmsg:/dev/kmsg:ro gcr.io/k8s-staging-npd/node-problem-detector:v1.37.0-alpha.1-31-g7bff5a4c-dirty \
  --enable-k8s-exporter=false \
  --prometheus-port=20257 \
  --config.custom-plugin-monitor=config/custom-plugin-monitor.json

❯ docker exec -ti npd bash
root@5bcbcdda7f64:/# apt update -qq; apt install -qq -y curl jq &>/dev/null
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@5bcbcdda7f64:/# curl -s http://127.0.0.1:20256/conditions | jq
[
  {
    "type": "ReadonlyFilesystem",
    "status": "False",
    "transition": "2026-08-03T12:41:01.208945846Z",
    "reason": "FilesystemIsNotReadOnly",
    "message": "Filesystem is not read-only"
  },
  {
    "type": "KernelDeadlock",
    "status": "False",
    "transition": "2026-08-03T12:41:01.208911429Z",
    "reason": "KernelHasNoDeadlock",
    "message": "kernel has no deadlock"
  },
  {
    "type": "XfsShutdown",
    "status": "False",
    "transition": "2026-08-03T12:41:01.208911554Z",
    "reason": "XfsHasNotShutDown",
    "message": "XFS has not shutdown"
  },
  {
    "type": "CperHardwareErrorFatal",
    "status": "False",
    "transition": "2026-08-03T12:41:01.208911596Z",
    "reason": "CperHardwareHasNoFatalError",
    "message": "UEFI CPER has no fatal error"
  },
  {
    "type": "NTPProblem",
    "status": "Unknown",
    "transition": "2026-08-03T12:41:01.214200471Z",
    "reason": "NTPIsUp",
    "message": "Could not find 'systemctl' - require systemd"
  }
]

@DigitalVeer DigitalVeer left a comment

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.

Thanks for the changes! We should also update the README. The README still has --address and --port under the "For Kubernetes exporter" heading.


// Package httpexporter provides a standalone HTTP server exposing /healthz,
// /conditions and /debug/pprof without requiring a Kubernetes API server.
package httpexporter

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.

Can we add tests for this package?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We don't have unit-tests for the other exporters. I can start adding unit-tests for sure, maybe it makes sense to cover unit-tests for the other exporters in a followup as well.

Comment thread cmd/nodeproblemdetector/node_problem_detector.go
@kubernetes-prow

Copy link
Copy Markdown
Contributor

@DigitalVeer: changing LGTM is restricted to collaborators

Details

In response to this:

Thanks for the changes! We should also update the README. The README still has --address and --port under the "For Kubernetes exporter" heading.

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.

Extract /healthz, /conditions and /debug/pprof into a new httpexporter
package so those endpoints are available when --enable-k8s-exporter=false.
Previously the HTTP server was started only inside the k8s exporter, making
it unavailable in non-Kubernetes environments. The new httpexporter tracks
conditions in-memory via ExportProblems and starts on --port regardless of
whether the Kubernetes API server is reachable.

Signed-off-by: Tobias Giese <tgiese@nvidia.com>
@tobiasgiese
tobiasgiese force-pushed the run-http-server-standalone branch from dc2b16e to dc0018e Compare August 10, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flag --enable-k8s-exporter=false causes loss of /healthz, /conditions, and /debug/pprof endpoints

2 participants