Documentation ¶
Overview ¶
Package health contains utilities for health checking, as well as health status information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHealthChecker ¶
func AddHealthChecker(checker HealthChecker)
AddHealthChecker adds a health checker to the list of known HealthChecker objects. Any subsequent call to NewHealthChecker will know about this HealthChecker.
Types ¶
type CommandRunner ¶
type ExecHealthChecker ¶
type ExecHealthChecker struct {
// contains filtered or unexported fields
}
func (*ExecHealthChecker) CanCheck ¶
func (e *ExecHealthChecker) CanCheck(probe *api.LivenessProbe) bool
type HTTPGetInterface ¶
HTTPGetInterface is an abstract interface for testability. It abstracts the interface of http.Client.Get. This is exported because some other packages may want to do direct HTTP checks.
type HTTPHealthChecker ¶
type HTTPHealthChecker struct {
// contains filtered or unexported fields
}
HTTPHealthChecker is an implementation of HealthChecker which checks container health by sending HTTP Get requests.
func (*HTTPHealthChecker) CanCheck ¶
func (h *HTTPHealthChecker) CanCheck(probe *api.LivenessProbe) bool
type HealthChecker ¶
type HealthChecker interface { HealthCheck(podFullName string, podUID types.UID, status api.PodStatus, container api.Container) (Status, error) CanCheck(probe *api.LivenessProbe) bool }
HealthChecker defines an abstract interface for checking container health.
func NewExecHealthChecker ¶
func NewExecHealthChecker(runner CommandRunner) HealthChecker
func NewHTTPHealthChecker ¶
func NewHTTPHealthChecker(client *http.Client) HealthChecker
func NewHealthChecker ¶
func NewHealthChecker() HealthChecker
NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.
type Status ¶
type Status int
Status represents the result of a single health-check operation.
func DoHTTPCheck ¶
func DoHTTPCheck(url string, client HTTPGetInterface) (Status, error)
DoHTTPCheck checks if a GET request to the url succeeds. If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Healthy. If the HTTP response code is unsuccessful or HTTP communication fails, it returns Unhealthy. This is exported because some other packages may want to do direct HTTP checks.
func DoTCPCheck ¶
DoTCPCheck checks that a TCP socket to the address can be opened. If the socket can be opened, it returns Healthy. If the socket fails to open, it returns Unhealthy. This is exported because some other packages may want to do direct TCP checks.
type TCPHealthChecker ¶
type TCPHealthChecker struct{}
func (*TCPHealthChecker) CanCheck ¶
func (t *TCPHealthChecker) CanCheck(probe *api.LivenessProbe) bool