healthcheck

package
v1.97.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ControllerName is the name of this controller.
	ControllerName = "health-check"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerdClient

type ContainerdClient interface {
	Version(context.Context) (containerd.Version, error)
}

ContainerdClient defines the containerd client Interface exported for testing.

type HealthChecker

type HealthChecker interface {
	// Name returns the name of the healthchecker.
	Name() string
	// Check executes the health check.
	Check(ctx context.Context, node *corev1.Node) error
}

HealthChecker can be implemented to run a health check against a node component and fix it if possible.

func NewContainerdHealthChecker

func NewContainerdHealthChecker(client client.Client, containerdClient ContainerdClient, clock clock.Clock, dbus dbus.DBus, recorder record.EventRecorder) HealthChecker

NewContainerdHealthChecker creates a new instance of a containerd health check.

type KubeletHealthChecker

type KubeletHealthChecker struct {
	// Clock exported for testing.
	Clock clock.Clock
	// KubeletReadinessToggles contains an entry for every toggle between NotReady->Ready state.
	KubeletReadinessToggles []time.Time
	// NodeReady indicates if the node is ready. Exported for testing.
	NodeReady bool
	// contains filtered or unexported fields
}

KubeletHealthChecker configures the kubelet healthcheck.

func NewKubeletHealthChecker

func NewKubeletHealthChecker(client client.Client, clock clock.Clock, dbus dbus.DBus, recorder record.EventRecorder, getAddresses func() ([]net.Addr, error)) *KubeletHealthChecker

NewKubeletHealthChecker create an instance of a kubelet health check.

func (*KubeletHealthChecker) Check

func (k *KubeletHealthChecker) Check(ctx context.Context, node *corev1.Node) error

Check performs the actual health check for the kubelet.

func (*KubeletHealthChecker) HasLastInternalIP

func (k *KubeletHealthChecker) HasLastInternalIP() bool

HasLastInternalIP returns true if the node.InternalIP was stored. Exported for testing.

func (*KubeletHealthChecker) Name

func (*KubeletHealthChecker) Name() string

Name returns the name of this health check.

func (*KubeletHealthChecker) RevertToggleKubeletState

func (k *KubeletHealthChecker) RevertToggleKubeletState()

RevertToggleKubeletState removes the last entry created by ToggleKubeletState().

func (*KubeletHealthChecker) SetKubeletHealthEndpoint

func (k *KubeletHealthChecker) SetKubeletHealthEndpoint(kubeletHealthEndpoint string)

SetKubeletHealthEndpoint set the kubeletHealthEndpoint. Exported for testing.

func (*KubeletHealthChecker) ToggleKubeletState

func (k *KubeletHealthChecker) ToggleKubeletState() bool

ToggleKubeletState should be triggered if the state of the kubelet changed from NotReady -> Ready. It returns true if a reboot of the node should be triggered.

type Reconciler

type Reconciler struct {
	Client                     client.Client
	Recorder                   record.EventRecorder
	DBus                       dbus.DBus
	HealthCheckers             []HealthChecker
	HealthCheckIntervalSeconds int32
}

Reconciler checks for containerd and kubelet health and restarts them if required.

func (*Reconciler) AddToManager

func (r *Reconciler) AddToManager(mgr manager.Manager, nodePredicate predicate.Predicate) error

AddToManager adds Reconciler to the given manager.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)

Reconcile executes all defined health checks.

Jump to

Keyboard shortcuts

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