podcommon

package
v0.0.0-...-86fc13e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationTargetContainerName = namespace + "/target-container-name"

	AnnotationCpuStartup             = namespace + "/cpu-startup"
	AnnotationCpuPostStartupRequests = namespace + "/cpu-post-startup-requests"
	AnnotationCpuPostStartupLimits   = namespace + "/cpu-post-startup-limits"

	AnnotationMemoryStartup             = namespace + "/memory-startup"
	AnnotationMemoryPostStartupRequests = namespace + "/memory-post-startup-requests"
	AnnotationMemoryPostStartupLimits   = namespace + "/memory-post-startup-limits"
)
View Source
const (
	AnnotationStatus = namespace + "/status"
)
View Source
const (
	LabelEnabled = namespace + "/enabled"
)

Variables

View Source
var KnownVpaAnnotations = []string{"vpaObservedContainers", "vpaUpdates"}

Functions

This section is empty.

Types

type CpuConfig

type CpuConfig struct {
	Startup             resource.Quantity
	PostStartupRequests resource.Quantity
	PostStartupLimits   resource.Quantity
}

CpuConfig holds CPU configuration.

func NewCpuConfig

func NewCpuConfig(
	startup resource.Quantity,
	postStartupRequests resource.Quantity,
	postStartupLimits resource.Quantity,
) CpuConfig

type MemoryConfig

type MemoryConfig struct {
	Startup             resource.Quantity
	PostStartupRequests resource.Quantity
	PostStartupLimits   resource.Quantity
}

MemoryConfig holds memory configuration.

func NewMemoryConfig

func NewMemoryConfig(
	startup resource.Quantity,
	postStartupRequests resource.Quantity,
	postStartupLimits resource.Quantity,
) MemoryConfig

type ScaleConfig

type ScaleConfig interface {
	GetTargetContainerName() string
	GetCpuConfig() CpuConfig
	GetMemoryConfig() MemoryConfig
	StoreFromAnnotations(*v1.Pod) error
	Validate() error
	String() string
}

ScaleConfig performs operations relating to scaling configuration.

type StateBool

type StateBool string

StateBool indicates the state of a boolean-like state.

const (
	StateBoolTrue    StateBool = "true"
	StateBoolFalse   StateBool = "false"
	StateBoolUnknown StateBool = "unknown"
)

func (StateBool) Bool

func (s StateBool) Bool() bool

Bool returns a bool representation.

type StateContainer

type StateContainer string

StateContainer indicates the state of a Kube container.

const (
	StateContainerRunning    StateContainer = "running"
	StateContainerWaiting    StateContainer = "waiting"
	StateContainerTerminated StateContainer = "terminated"
	StateContainerUnknown    StateContainer = "unknown"
)

type StateResources

type StateResources string

StateResources indicates what Kube container resources are set.

const (
	StateResourcesStartup     StateResources = "startup"
	StateResourcesPostStartup StateResources = "poststartup"
	StateResourcesUnknown     StateResources = "unknown"
)

func (StateResources) Direction

func (s StateResources) Direction() metricscommon.Direction

Direction returns the scale direction.

func (StateResources) HumanReadable

func (s StateResources) HumanReadable() string

HumanReadable returns a string suitable to include within human-readable messages.

type StateStatusResources

type StateStatusResources string

StateStatusResources indicates the state of a Kube container's status resources.

const (
	// StateStatusResourcesIncomplete indicates status resources are incomplete.
	StateStatusResourcesIncomplete StateStatusResources = "incomplete"

	// StateStatusResourcesContainerResourcesMatch indicates status resources match container resources.
	StateStatusResourcesContainerResourcesMatch StateStatusResources = "containerresourcesmatch"

	// StateStatusResourcesContainerResourcesMismatch indicates status resources don't match container resources.
	StateStatusResourcesContainerResourcesMismatch StateStatusResources = "containerresourcesmismatch"

	// StateStatusResourcesUnknown indicates status resources are unknown.
	StateStatusResourcesUnknown StateStatusResources = "unknown"
)

type States

type States struct {
	StartupProbe    StateBool            `json:"startupProbe"`
	ReadinessProbe  StateBool            `json:"readinessProbe"`
	Container       StateContainer       `json:"container"`
	Started         StateBool            `json:"started"`
	Ready           StateBool            `json:"ready"`
	Resources       StateResources       `json:"resources"`
	StatusResources StateStatusResources `json:"statusResources"`
}

States holds information related to the current state of the target container.

func NewStates

func NewStates(
	startupProbe StateBool,
	readinessProbe StateBool,
	stateContainer StateContainer,
	started StateBool,
	ready StateBool,
	stateResources StateResources,
	stateStatusResources StateStatusResources,
) States

func NewStatesAllUnknown

func NewStatesAllUnknown() States

type StatusAnnotation

type StatusAnnotation struct {
	Status      string                `json:"status"`
	States      States                `json:"states"`
	Scale       StatusAnnotationScale `json:"scale"`
	LastUpdated string                `json:"lastUpdated"`
}

StatusAnnotation holds status information that's serialized to JSON for status reporting.

func NewStatusAnnotation

func NewStatusAnnotation(
	status string,
	states States,
	scale StatusAnnotationScale,
	lastUpdated string,
) StatusAnnotation

func StatusAnnotationFromString

func StatusAnnotationFromString(s string) (StatusAnnotation, error)

StatusAnnotationFromString returns a status annotation from s.

func (StatusAnnotation) Equal

Equal reports whether this is to equal to another.

func (StatusAnnotation) Json

func (s StatusAnnotation) Json() string

Json returns a JSON string.

type StatusAnnotationScale

type StatusAnnotationScale struct {
	LastCommanded string `json:"lastCommanded"`
	LastEnacted   string `json:"lastEnacted"`
	LastFailed    string `json:"lastFailed"`
}

StatusAnnotationScale holds scale-related information that's serialized to JSON for status reporting.

func NewEmptyStatusAnnotationScale

func NewEmptyStatusAnnotationScale() StatusAnnotationScale

func NewStatusAnnotationScale

func NewStatusAnnotationScale(
	lastCommanded string,
	lastEnacted string,
	lastFailed string,
) StatusAnnotationScale

type StatusScaleState

type StatusScaleState string

StatusScaleState indicates the scale state for status purposes.

const (
	// StatusScaleStateNotApplicable indicates the scale state is not applicable.
	StatusScaleStateNotApplicable StatusScaleState = "notapplicable"

	// StatusScaleStateUpCommanded indicates scaling up commanded.
	StatusScaleStateUpCommanded StatusScaleState = "upcommanded"

	// StatusScaleStateUpEnacted indicates scaling up enacted.
	StatusScaleStateUpEnacted StatusScaleState = "upenacted"

	// StatusScaleStateUpFailed indicates scaling up failed.
	StatusScaleStateUpFailed StatusScaleState = "upfailed"

	// StatusScaleStateDownCommanded indicates scaling down commanded.
	StatusScaleStateDownCommanded StatusScaleState = "downcommanded"

	// StatusScaleStateDownEnacted indicates scaling down enacted.
	StatusScaleStateDownEnacted StatusScaleState = "downenacted"

	// StatusScaleStateDownFailed indicates scaling down failed.
	StatusScaleStateDownFailed StatusScaleState = "downfailed"

	// StatusScaleStateUnknownCommanded indicates scaling in an unknown direction commanded.
	StatusScaleStateUnknownCommanded StatusScaleState = "unknowncommanded"
)

func (StatusScaleState) Direction

Direction returns the scale direction.

type Type

type Type string

Type indicates a data type.

const (
	TypeString Type = "string"
	TypeBool   Type = "bool"
)

Jump to

Keyboard shortcuts

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