liveness

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package liveness implements Kubernetes health checks for the controller. The health checks affect whether the controller is considered alive or dead (in which case it is restarted).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityName added in v1.2.5

type ActivityName int

ActivityName represents the actions of the controller which are monitored by the health checks.

const (
	// Undefined indicates a default action.
	Undefined ActivityName = iota

	// SynchronizeAll indicates a Controller.SynchronizeAll() call.
	SynchronizeAll

	// McrtResyncProcess indicates a ManagedCertificate object is
	// processed by the lower priority queue in the controller.
	McrtResyncProcess

	// IngressResyncProcess indicates an Ingress object is processed by
	// the lower priority queue in the controller.
	IngressResyncProcess
)

type HealthCheck

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

HealthCheck implements an HTTP endpoint through which it communicates the liveness status of the controller by responding with 2xx HTTP codes when the controller is alive and with 5xx HTTP codes when it is dead.

HealthCheck tracks the last time of when the following actions were performed by the controller and when they succeeded: - SynchronizeAll: Add all known resources to the controller queues. - McrtResyncProcess, IngressResyncProcess: process ManagedCertificate or Ingress, respectively, on a low priority workqueue.

- If the last time SynchronizeAll was performed or succeeded is too far ago, HealthCheck will respond that the controller is dead. - If an Ingress or a ManagedCertificate resource was queued for processing by the *previous* SynchronizeAll call and was not processed until `syncSuccessTimeout` elapses, HealthCheck will respond that the controller is dead. - If health checking is not running, it always responds that the controller is alive. It is not running by default.

## Usage

# Create health check with h := liveness.NewHealthCheck()

# Begin serving the liveness status h.StartServing()

# When ready, after the instance elected as a master, begin monitoring h.StartMonitoring()

# End monitoring and shut down h.Stop()

func NewHealthCheck

func NewHealthCheck(healthCheckInterval, activityTimeout,
	successTimeout time.Duration) *HealthCheck

NewHealthCheck builds new HealthCheck object with given timeout.

func (*HealthCheck) StartMonitoring

func (hc *HealthCheck) StartMonitoring()

StartMonitoring starts controller health checks. After StartMonitoring is called, the probe starts monitoring the healthiness of the controller and may report that it is dead. Monitoring runs every healthCheckInterval until Stop() is called.

func (*HealthCheck) StartServing added in v1.2.9

func (hc *HealthCheck) StartServing(address, path string)

StartServing starts the liveness probe http server. After StartServing is called, the probe starts reporting its status to Kubelet on the endpoint `address`/`path`.

func (*HealthCheck) Stop added in v1.2.5

func (hc *HealthCheck) Stop() error

Stop stops controller health checks and the liveness probe http server.

func (*HealthCheck) UpdateLastActivity added in v1.2.5

func (hc *HealthCheck) UpdateLastActivity(activityName ActivityName, timestamp time.Time)

UpdateLastActivity updates last time of an activity.

func (*HealthCheck) UpdateLastSuccessSync added in v1.2.5

func (hc *HealthCheck) UpdateLastSuccessSync(timestamp time.Time,
	ingressScheduled, mcrtScheduled bool)

UpdateLastSuccessSync updates last time of successful (i.e. not ending in error) Controller.synchronizeAll activity.

Directories

Path Synopsis
Package testhelpers defines helpers for liveness package.
Package testhelpers defines helpers for liveness package.

Jump to

Keyboard shortcuts

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