minimizepower

package
v1.27.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AssumedCPUUsageRate sets Pod CPU usage to (limits.cpu * AssumedCPUUsageRate) if requests.cpu is empty.
	AssumedCPUUsageRate = 0.85
	// LowerLimitCPUUsageRate sets the lowest Pod CPU usage to (limits.cpu * LowerLimitCPUUsageRate) for the score calculation.
	LowerLimitCPUUsageRate = 0.50

	// MetricsCacheTTL is the expiration time of the metrics cache.
	MetricsCacheTTL = 15 * time.Second
	// PredictorCacheTTL is the expiration time of the predictor cache.
	PredictorCacheTTL = 15 * time.Second
)

Variables

View Source
var (
	Name = "MinimizePower"
)

Functions

func AssumedPodCPUUsage

func AssumedPodCPUUsage(pod *corev1.Pod, assumedCPUUsageRate float64) (v float64)

AssumedPodCPUUsage assumes the total CPU usage by the given Pod.

ContainerCPUUsage = requests.cpu || limits.cpu * assumedCPUUsageRate PodCPUUsage = [sum(ContainerCPUUsage(c)) for c in spec.containers] Ignore Pods with no requests.cpu and limits.cpu

func New

New initializes a new plugin and returns it.

func PodCPULimit

func PodCPULimit(pod *corev1.Pod) (v float64)

func PodCPURequest

func PodCPURequest(pod *corev1.Pod) (v float64)

func PodCPUUsage

func PodCPUUsage(podMetrics *metricsv1beta1.PodMetrics) (v float64)

func PowerConsumptions2Scores

func PowerConsumptions2Scores(scores framework.NodeScoreList)

Types

type MinimizePower

type MinimizePower struct {
	// contains filtered or unexported fields
}

func (*MinimizePower) AssumedCPUUsage

func (pl *MinimizePower) AssumedCPUUsage(ctx context.Context,
	node *corev1.Node, nodeMetrics *metricsv1beta1.NodeMetrics,
	nodePods []*corev1.Pod, nodePodsMetricses []*metricsv1beta1.PodMetrics,
	pod *corev1.Pod,
	assumedCPUUsageRate float64, lowerLimitCPUUsageRate float64,
) (before float64, after float64)

AssumedCPUUsage assumes the CPU usage increment by allocating the given Pod.

  • Node CPU usage may be greater than 1.0.
  • Containers are ignored when it has empty requests.cpu and empty limit.cpu.
  • assumedCPUUsageRate is used when a container has empty requests.cpu and non-empty limits.cpu.
  • lowerLimitCPUUsageRate is the lower limit CPU usage rate of a pod.

func (*MinimizePower) Name

func (*MinimizePower) Name() string

Name returns name of the plugin. It is used in logs, etc.

func (*MinimizePower) NormalizeScore

func (*MinimizePower) Score

func (pl *MinimizePower) Score(ctx context.Context, state *framework.CycleState, pod *corev1.Pod, nodeName string) (int64, *framework.Status)

Score returns how many watts will be increased by the given pod (lower is better).

This function never returns an error (as errors cause the pod to be rejected). If an error occurs, it is logged and the score is set to math.MaxInt64.

func (*MinimizePower) ScoreExtensions

func (pl *MinimizePower) ScoreExtensions() framework.ScoreExtensions

ScoreExtensions returns a ScoreExtensions interface.

Jump to

Keyboard shortcuts

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