autoscaling

package
v1.23.6-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 23 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// KindRC is the GVK for ReplicationController
	KindRC = schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"}
	// KindDeployment is the GVK for Deployment
	KindDeployment = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "Deployment"}
	// KindReplicaSet is the GVK for ReplicaSet
	KindReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "ReplicaSet"}
)

Functions

func CreateCPUHorizontalPodAutoscaler

func CreateCPUHorizontalPodAutoscaler(rc *ResourceConsumer, cpu, minReplicas, maxRepl int32) *autoscalingv1.HorizontalPodAutoscaler

CreateCPUHorizontalPodAutoscaler create a horizontalPodAutoscaler with CPU target for consuming resources.

func CreateContainerResourceCPUHorizontalPodAutoscaler added in v1.23.0

func CreateContainerResourceCPUHorizontalPodAutoscaler(rc *ResourceConsumer, cpu, minReplicas, maxRepl int32) *autoscalingv2.HorizontalPodAutoscaler

CreateContainerResourceCPUHorizontalPodAutoscaler create a horizontal pod autoscaler with container resource target for consuming resources.

func DeleteContainerResourceHPA added in v1.23.0

func DeleteContainerResourceHPA(rc *ResourceConsumer, autoscalerName string)

DeleteContainerResourceHPA delete the horizontalPodAutoscaler for consuming resources.

func DeleteHorizontalPodAutoscaler

func DeleteHorizontalPodAutoscaler(rc *ResourceConsumer, autoscalerName string)

DeleteHorizontalPodAutoscaler delete the horizontalPodAutoscaler for consuming resources.

Types

type ResourceConsumer

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

ResourceConsumer is a tool for testing. It helps create specified usage of CPU or memory (Warning: memory not supported) typical use case: rc.ConsumeCPU(600) // ... check your assumption here rc.ConsumeCPU(300) // ... check your assumption here

func NewDynamicResourceConsumer

func NewDynamicResourceConsumer(name, nsName string, kind schema.GroupVersionKind, replicas, initCPUTotal, initMemoryTotal, initCustomMetric int, cpuLimit, memLimit int64, clientset clientset.Interface, scaleClient scaleclient.ScalesGetter, enableSidecar SidecarStatusType, sidecarType SidecarWorkloadType) *ResourceConsumer

NewDynamicResourceConsumer is a wrapper to create a new dynamic ResourceConsumer

func (*ResourceConsumer) CleanUp

func (rc *ResourceConsumer) CleanUp()

CleanUp clean up the background goroutines responsible for consuming resources.

func (*ResourceConsumer) ConsumeCPU

func (rc *ResourceConsumer) ConsumeCPU(millicores int)

ConsumeCPU consumes given number of CPU

func (*ResourceConsumer) ConsumeCustomMetric

func (rc *ResourceConsumer) ConsumeCustomMetric(amount int)

ConsumeCustomMetric consumes given number of custom metric

func (*ResourceConsumer) ConsumeMem

func (rc *ResourceConsumer) ConsumeMem(megabytes int)

ConsumeMem consumes given number of Mem

func (*ResourceConsumer) EnsureDesiredReplicasInRange

func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string)

EnsureDesiredReplicasInRange ensure the replicas is in a desired range

func (*ResourceConsumer) GetHpa

GetHpa get the corresponding horizontalPodAutoscaler object

func (*ResourceConsumer) GetReplicas

func (rc *ResourceConsumer) GetReplicas() int

GetReplicas get the replicas

func (*ResourceConsumer) Pause

func (rc *ResourceConsumer) Pause()

Pause stops background goroutines responsible for consuming resources.

func (*ResourceConsumer) Resume

func (rc *ResourceConsumer) Resume()

Resume starts background goroutines responsible for consuming resources.

func (*ResourceConsumer) WaitForReplicas

func (rc *ResourceConsumer) WaitForReplicas(desiredReplicas int, duration time.Duration)

WaitForReplicas wait for the desired replicas

type SidecarStatusType added in v1.23.0

type SidecarStatusType bool

SidecarStatusType type for sidecar status

const (
	Enable  SidecarStatusType = true
	Disable SidecarStatusType = false
)

type SidecarWorkloadType added in v1.23.0

type SidecarWorkloadType string

SidecarWorkloadType type of the sidecar

const (
	Busy SidecarWorkloadType = "Busy"
	Idle SidecarWorkloadType = "Idle"
)

Jump to

Keyboard shortcuts

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