kubernetes

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResmgrKeyNamespace is a NRI Resource Policy namespace
	ResmgrKeyNamespace = "resource-policy.nri.io"

	// NamespaceSystem is the kubernetes system namespace.
	NamespaceSystem = "kube-system"
	// PodNameLabel is the key for the kubernetes pod name label.
	PodNameLabel = "io.kubernetes.pod.name"
	// ContainerNameLabel is the key for the kubernetes container name label.
	ContainerNameLabel = "io.kubernetes.container.name"
)
View Source
const (

	// MinShares is the minimum cpu.shares accepted by cgroups.
	MinShares = 2
	// MaxShares is the minimum cpu.shares accepted by cgroups.
	MaxShares = 262144
	// SharesPerCPU is cpu.shares worth one full CPU.
	SharesPerCPU = 1024
	// MilliCPUToCPU is milli-CPUs worth a full CPU.
	MilliCPUToCPU = 1000
	// QuotaPeriod is 100000 microseconds, or 100ms
	QuotaPeriod = 100000
	// MinQuotaPeriod is 1000 microseconds, or 1ms
	MinQuotaPeriod = 1000

	GuaranteedOOMScoreAdj = -997
	BestEffortOOMScoreAdj = 1000

	MinBurstableOOMScoreAdj = 1000 + GuaranteedOOMScoreAdj // 1000 - 997 = 3
	MaxBurstableOOMScoreAdj = BestEffortOOMScoreAdj - 1    // 1000 - 1 = 999

)

Variables

This section is empty.

Functions

func CalculateOomAdjToMemReqEstimates added in v0.9.0

func CalculateOomAdjToMemReqEstimates() map[int64]int64

CalculateOomAdjToMemReqEstimates calculates a table of memory request estimates for OOM score adjustments in the range [0, 1000].

func GetMemoryCapacity added in v0.9.0

func GetMemoryCapacity() int64

func MemReqToOomAdj added in v0.9.0

func MemReqToOomAdj(memRequest int64) int64

MemReqToOomAdj estimates OOM score adjustment based on memory request.

func MilliCPUToQuota

func MilliCPUToQuota(milliCPU int64) (quota, period int64)

MilliCPUToQuota converts milliCPU to CFS quota and period values. (Almost) identical to the same function in kubelet.

func MilliCPUToShares

func MilliCPUToShares(milliCPU int64) uint64

MilliCPUToShares converts the milliCPU to CFS shares. Identical to the same function in kubelet.

func OomAdjToMemReq added in v0.9.0

func OomAdjToMemReq(oomAdj int64, memLimit int64) *int64

OomAdjToMemReq estimates memory request based on OOM score adjustment.

func QuotaToMilliCPU

func QuotaToMilliCPU(quota, period int64) int64

QuotaToMilliCPU converts CFS quota and period to milli-CPUs.

func ResmgrKey

func ResmgrKey(name string) string

ResmgrKey returns a full namespaced name of a resource manager specific key

func SetMemoryCapacity added in v0.9.0

func SetMemoryCapacity(capacity int64)

Set memory capacity for OOM adjustment to memory request estimation. Exported to allow testing the estimator code with different memory capacities.

func SharesToMilliCPU

func SharesToMilliCPU(shares int64) int64

SharesToMilliCPU converts CFS CPU shares to milli-CPUs.

func ShortCPUSet

func ShortCPUSet(cset cpuset.CPUSet) string

ShortCPUSet prints the cpuset as a string, trying to further shorten compared to .String().

Types

This section is empty.

Jump to

Keyboard shortcuts

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