eviction

package
v1.30.4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: Apache-2.0 Imports: 30 Imported by: 102

Documentation

Overview

Package eviction is responsible for enforcing eviction thresholds to maintain node stability.

Index

Constants

View Source
const (

	// Reason is the reason reported back in status.
	Reason = "Evicted"

	// OffendingContainersKey is the key in eviction event annotations for the list of container names which exceeded their requests
	OffendingContainersKey = "offending_containers"
	// OffendingContainersUsageKey is the key in eviction event annotations for the list of usage of containers which exceeded their requests
	OffendingContainersUsageKey = "offending_containers_usage"
	// StarvedResourceKey is the key for the starved resource in eviction event annotations
	StarvedResourceKey = "starved_resource"
)

Variables

View Source
var DefaultEvictionHard = map[string]string{
	"memory.available":   "100Mi",
	"nodefs.available":   "10%",
	"nodefs.inodesFree":  "5%",
	"imagefs.available":  "15%",
	"imagefs.inodesFree": "5%",
}

DefaultEvictionHard includes default options for hard eviction.

Functions

func ParseThresholdConfig

func ParseThresholdConfig(allocatableConfig []string, evictionHard, evictionSoft, evictionSoftGracePeriod, evictionMinimumReclaim map[string]string) ([]evictionapi.Threshold, error)

ParseThresholdConfig parses the flags for thresholds.

func PodIsEvicted added in v1.4.0

func PodIsEvicted(podStatus v1.PodStatus) bool

PodIsEvicted returns true if the reported pod status is due to an eviction.

func UpdateContainerFsThresholds added in v1.29.0

func UpdateContainerFsThresholds(thresholds []evictionapi.Threshold, imageFs, separateContainerImageFs bool) ([]evictionapi.Threshold, error)

UpdateContainerFsThresholds will add containerfs eviction hard/soft settings based on container runtime settings. Thresholds are parsed from evictionHard and evictionSoft limits so we will override. If there is a single filesystem, then containerfs settings are same as nodefs. If there is a separate image filesystem for both containers and images then containerfs settings are same as imagefs.

Types

type ActivePodsFunc

type ActivePodsFunc func() []*v1.Pod

ActivePodsFunc returns pods bound to the kubelet that are active (i.e. non-terminal state)

type CgroupNotifier added in v1.11.0

type CgroupNotifier interface {
	// Start causes the CgroupNotifier to begin notifying on the eventCh
	Start(eventCh chan<- struct{})
	// Stop stops all processes and cleans up file descriptors associated with the CgroupNotifier
	Stop()
}

CgroupNotifier generates events from cgroup events

func NewCgroupNotifier added in v1.11.0

func NewCgroupNotifier(path, attribute string, threshold int64) (CgroupNotifier, error)

NewCgroupNotifier returns a linuxCgroupNotifier, which performs cgroup control operations required to receive notifications from the cgroup when the threshold is crossed in either direction.

type CgroupNotifierFactory added in v1.11.0

type CgroupNotifierFactory struct{}

CgroupNotifierFactory knows how to make CgroupNotifiers which integrate with the kernel

func (*CgroupNotifierFactory) NewCgroupNotifier added in v1.11.0

func (n *CgroupNotifierFactory) NewCgroupNotifier(path, attribute string, threshold int64) (CgroupNotifier, error)

NewCgroupNotifier implements the NotifierFactory interface

type Config

type Config struct {
	// PressureTransitionPeriod is duration the kubelet has to wait before transitioning out of a pressure condition.
	PressureTransitionPeriod time.Duration
	// Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met.
	MaxPodGracePeriodSeconds int64
	// Thresholds define the set of conditions monitored to trigger eviction.
	Thresholds []evictionapi.Threshold
	// KernelMemcgNotification if true will integrate with the kernel memcg notification to determine if memory thresholds are crossed.
	KernelMemcgNotification bool
	// PodCgroupRoot is the cgroup which contains all pods.
	PodCgroupRoot string
}

Config holds information about how eviction is configured.

type ContainerGC added in v1.7.0

type ContainerGC interface {
	// DeleteAllUnusedContainers deletes all unused containers, even those that belong to pods that are terminated, but not deleted.
	DeleteAllUnusedContainers(ctx context.Context) error
	// IsContainerFsSeparateFromImageFs checks if container filesystem is split from image filesystem.
	IsContainerFsSeparateFromImageFs(ctx context.Context) bool
}

ContainerGC is responsible for performing garbage collection of unused containers.

type DiskInfoProvider added in v1.4.0

type DiskInfoProvider interface {
	// HasDedicatedImageFs returns true if the imagefs is on a separate device from the rootfs.
	HasDedicatedImageFs(ctx context.Context) (bool, error)
}

DiskInfoProvider is responsible for informing the manager how disk is configured.

type ImageGC added in v1.4.0

type ImageGC interface {
	// DeleteUnusedImages deletes unused images.
	DeleteUnusedImages(ctx context.Context) error
}

ImageGC is responsible for performing garbage collection of unused images.

type KillPodFunc

type KillPodFunc func(pod *v1.Pod, isEvicted bool, gracePeriodOverride *int64, fn func(*v1.PodStatus)) error

KillPodFunc kills a pod. The pod status is updated, and then it is killed with the specified grace period. This function must block until either the pod is killed or an error is encountered. Arguments: pod - the pod to kill status - the desired status to associate with the pod (i.e. why its killed) gracePeriodOverride - the grace period override to use instead of what is on the pod spec

type Manager

type Manager interface {
	// Start starts the control loop to monitor eviction thresholds at specified interval.
	Start(diskInfoProvider DiskInfoProvider, podFunc ActivePodsFunc, podCleanedUpFunc PodCleanedUpFunc, monitoringInterval time.Duration)

	// IsUnderMemoryPressure returns true if the node is under memory pressure.
	IsUnderMemoryPressure() bool

	// IsUnderDiskPressure returns true if the node is under disk pressure.
	IsUnderDiskPressure() bool

	// IsUnderPIDPressure returns true if the node is under PID pressure.
	IsUnderPIDPressure() bool
}

Manager evaluates when an eviction threshold for node stability has been met on the node.

func NewManager

func NewManager(
	summaryProvider stats.SummaryProvider,
	config Config,
	killPodFunc KillPodFunc,
	imageGC ImageGC,
	containerGC ContainerGC,
	recorder record.EventRecorder,
	nodeRef *v1.ObjectReference,
	clock clock.WithTicker,
	localStorageCapacityIsolation bool,
) (Manager, lifecycle.PodAdmitHandler)

NewManager returns a configured Manager and an associated admission handler to enforce eviction configuration.

type MirrorPodFunc added in v1.11.10

type MirrorPodFunc func(*v1.Pod) (*v1.Pod, bool)

MirrorPodFunc returns the mirror pod for the given static pod and whether it was known to the pod manager.

type NotifierFactory added in v1.11.0

type NotifierFactory interface {
	// NewCgroupNotifier creates a CgroupNotifier that creates events when the threshold
	// on the attribute in the cgroup specified by the path is crossed.
	NewCgroupNotifier(path, attribute string, threshold int64) (CgroupNotifier, error)
}

NotifierFactory creates CgroupNotifer

type PodCleanedUpFunc added in v1.7.0

type PodCleanedUpFunc func(*v1.Pod) bool

PodCleanedUpFunc returns true if all resources associated with a pod have been reclaimed.

type ThresholdNotifier added in v1.5.0

type ThresholdNotifier interface {
	// Start calls the notifier function when the CgroupNotifier notifies the ThresholdNotifier that an event occurred
	Start()
	// UpdateThreshold updates the memory cgroup threshold based on the metrics provided.
	// Calling UpdateThreshold with recent metrics allows the ThresholdNotifier to trigger at the
	// eviction threshold more accurately
	UpdateThreshold(summary *statsapi.Summary) error
	// Description produces a relevant string describing the Memory Threshold Notifier
	Description() string
}

ThresholdNotifier manages CgroupNotifiers based on memory eviction thresholds, and performs a function when memory eviction thresholds are crossed

func NewMemoryThresholdNotifier added in v1.11.0

func NewMemoryThresholdNotifier(threshold evictionapi.Threshold, cgroupRoot string, factory NotifierFactory, handler func(string)) (ThresholdNotifier, error)

NewMemoryThresholdNotifier creates a ThresholdNotifier which is designed to respond to the given threshold. UpdateThreshold must be called once before the threshold will be active.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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