healthz

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 982

Documentation

Overview

Package healthz implements basic http server health checking. Usage:

import "k8s.io/apiserver/pkg/server/healthz"
healthz.InstallHandler(mux)

Index

Constants

View Source
const DefaultHealthzPath = "/healthz"

Variables

This section is empty.

Functions

func InstallHandler

func InstallHandler(mux mux, checks ...HealthChecker)

InstallHandler registers handlers for health checking on the path "/healthz" to mux. *All handlers* for mux must be specified in exactly one call to InstallHandler. Calling InstallHandler more than once for the same mux will result in a panic.

func InstallLivezHandler added in v0.16.4

func InstallLivezHandler(mux mux, checks ...HealthChecker)

InstallLivezHandler registers handlers for liveness checking on the path "/livez" to mux. *All handlers* for mux must be specified in exactly one call to InstallHandler. Calling InstallHandler more than once for the same mux will result in a panic.

func InstallPathHandler

func InstallPathHandler(mux mux, path string, checks ...HealthChecker)

InstallPathHandler registers handlers for health checking on a specific path to mux. *All handlers* for the path must be specified in exactly one call to InstallPathHandler. Calling InstallPathHandler more than once for the same path and mux will result in a panic.

func InstallPathHandlerWithHealthyFunc added in v0.22.0

func InstallPathHandlerWithHealthyFunc(mux mux, path string, firstTimeHealthy func(), checks ...HealthChecker)

InstallPathHandlerWithHealthyFunc is like InstallPathHandler, but calls firstTimeHealthy exactly once when the handler succeeds for the first time.

func InstallReadyzHandler added in v0.16.4

func InstallReadyzHandler(mux mux, checks ...HealthChecker)

InstallReadyzHandler registers handlers for health checking on the path "/readyz" to mux. *All handlers* for mux must be specified in exactly one call to InstallHandler. Calling InstallHandler more than once for the same mux will result in a panic.

Types

type HealthChecker added in v0.16.4

type HealthChecker interface {
	Name() string
	Check(req *http.Request) error
}

HealthChecker is a named healthz checker.

var LogHealthz HealthChecker = &log{}

LogHealthz returns true if logging is not blocked

var PingHealthz HealthChecker = ping{}

PingHealthz returns true automatically when checked

func NamedCheck

func NamedCheck(name string, check func(r *http.Request) error) HealthChecker

NamedCheck returns a healthz checker for the given name and function.

func NewInformerSyncHealthz added in v0.16.13

func NewInformerSyncHealthz(cacheSyncWaiter cacheSyncWaiter) HealthChecker

NewInformerSyncHealthz returns a new HealthChecker that will pass only if all informers in the given cacheSyncWaiter sync.

func NewShutdownHealthz added in v0.31.0

func NewShutdownHealthz(stopCh <-chan struct{}) HealthChecker

NewShutdownHealthz returns a new HealthChecker that will fail if the embedded channel is closed. This is intended to allow for graceful shutdown sequences.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL