kubernetes: github.com/igm/kubernetes/pkg/health Index | Files

package health

import "github.com/igm/kubernetes/pkg/health"

Package health contains utilities for health checking, as well as health status information.

Index

Package Files

doc.go exec.go health.go http.go tcp.go

func AddHealthChecker Uses

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.

type CommandRunner Uses

type CommandRunner interface {
    RunInContainer(podFullName, uuid, containerName string, cmd []string) ([]byte, error)
}

type ExecHealthChecker Uses

type ExecHealthChecker struct {
    // contains filtered or unexported fields
}

func (*ExecHealthChecker) CanCheck Uses

func (e *ExecHealthChecker) CanCheck(probe *api.LivenessProbe) bool

func (*ExecHealthChecker) HealthCheck Uses

func (e *ExecHealthChecker) HealthCheck(podFullName, podUUID string, currentState api.PodState, container api.Container) (Status, error)

type HTTPGetInterface Uses

type HTTPGetInterface interface {
    Get(url string) (*http.Response, error)
}

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 Uses

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 Uses

func (h *HTTPHealthChecker) CanCheck(probe *api.LivenessProbe) bool

func (*HTTPHealthChecker) HealthCheck Uses

func (h *HTTPHealthChecker) HealthCheck(podFullName, podUUID string, currentState api.PodState, container api.Container) (Status, error)

HealthCheck checks if the container is healthy by trying sending HTTP Get requests to the container.

type HealthChecker Uses

type HealthChecker interface {
    HealthCheck(podFullName, podUUID string, currentState api.PodState, container api.Container) (Status, error)
    CanCheck(probe *api.LivenessProbe) bool
}

HealthChecker defines an abstract interface for checking container health.

func NewExecHealthChecker Uses

func NewExecHealthChecker(runner CommandRunner) HealthChecker

func NewHTTPHealthChecker Uses

func NewHTTPHealthChecker(client *http.Client) HealthChecker

func NewHealthChecker Uses

func NewHealthChecker() HealthChecker

NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.

type Status Uses

type Status int

Status represents the result of a single health-check operation.

const (
    Healthy Status = iota
    Unhealthy
    Unknown
)

Status values must be one of these constants.

func DoHTTPCheck Uses

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, it returns Unhealthy. It returns Unknown and err if the HTTP communication itself fails. This is exported because some other packages may want to do direct HTTP checks.

func DoTCPCheck Uses

func DoTCPCheck(addr string) (Status, error)

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.

func (Status) String Uses

func (s Status) String() string

type TCPHealthChecker Uses

type TCPHealthChecker struct{}

func (*TCPHealthChecker) CanCheck Uses

func (t *TCPHealthChecker) CanCheck(probe *api.LivenessProbe) bool

func (*TCPHealthChecker) HealthCheck Uses

func (t *TCPHealthChecker) HealthCheck(podFullName, podUUID string, currentState api.PodState, container api.Container) (Status, error)

Package health imports 10 packages (graph). Updated 2018-04-17. Refresh now. Tools for package owners.