feat: run HTTP server standalone without Kubernetes - #1333
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tobiasgiese The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Can we add tests for this package?
There was a problem hiding this comment.
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.
|
@DigitalVeer: changing LGTM is restricted to collaborators DetailsIn response to this:
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. |
5fde43a to
dc2b16e
Compare
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>
dc2b16e to
dc0018e
Compare
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.