controller

package
v0.0.0-...-b39e775 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// TerminationReasonOOMKilled is the reason of a ContainerStateTerminated that reflects an OOM kill
	TerminationReasonOOMKilled = "OOMKilled"
)

Variables

View Source
var (
	// ProcessedContainerUpdates stores the number of processed containers
	ProcessedContainerUpdates = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "kubernetes_oom_event_generator",
		Name:      "container_updates_processed_total",
		Help:      "The total number of processed container updates.",
	}, []string{"update_type"})
)

Functions

func WithAllowedNamespaces

func WithAllowedNamespaces(value []string) controllerOption

WithAllowedNamespaces sets the corresponding field in a controllerConfig type.

func WithAllowedUpdateNamespaces

func WithAllowedUpdateNamespaces(value []string) controllerOption

WithAllowedUpdateNamespaces sets the corresponding field in a controllerConfig type.

func WithUpdateMemoryLimits

func WithUpdateMemoryLimits(value bool) controllerOption

WithUpdateMemoryLimits sets the corresponding field in a controllerConfig type.

func WithUpdateMemoryLimitsIncrement

func WithUpdateMemoryLimitsIncrement(value float64) controllerOption

WithUpdateMemoryLimitsIncrement sets the corresponding field in a controllerConfig type.

func WithUpdateMemoryLimitsMax

func WithUpdateMemoryLimitsMax(value float64) controllerOption

WithUpdateMemoryLimitsMax sets the corresponding field in a controllerConfig type.

func WithUpdateMemoryLimitsMinimumOOMs

func WithUpdateMemoryLimitsMinimumOOMs(value int64) controllerOption

WithUpdateMemoryLimitsMinimumOOMs sets the corresponding field in a controllerConfig type.

Types

type Controller

type Controller struct {
	Stop chan struct{}
	// contains filtered or unexported fields
}

Controller is a controller that listens for Pod OOM-kill events, optionally changes memory limits of the pod-controller, and manages action-items in an Insights report.

func NewController

func NewController(stop chan struct{}, kubeClientResources util.KubeClientResources, rb *report.RightSizerReportBuilder, options ...controllerOption) *Controller

NewController returns an instance of the Controller, setting configuration defaults unless optional configuration is specified by calling `Withxxx()` functions as parameters to this constructor.

func (*Controller) Run

func (c *Controller) Run() error

Run is the main loop that processes Kubernetes Pod changes

func (*Controller) UpdateMemoryLimitsPrecheck

func (c *Controller) UpdateMemoryLimitsPrecheck(namespace string, OOMs int64) (bool, string)

UpdateMemoryLimitsPrecheck returns true if the controller configuration would allow memory limits to be updated for the specified Kube namespace and a number of out-of-memory-kills. If this determination is false, the string return argument provides the reason updating is not allowed, for use logging upstream where additional context is available.

Jump to

Keyboard shortcuts

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