Documentation ¶
Index ¶
- Variables
- func CreateCPUHorizontalPodAutoscalerWithBehavior(rc *ResourceConsumer, cpu int32, minReplicas int32, maxRepl int32, ...) *autoscalingv2.HorizontalPodAutoscaler
- func CreateCPUResourceHorizontalPodAutoscaler(rc *ResourceConsumer, cpu, minReplicas, maxReplicas int32) *autoscalingv2.HorizontalPodAutoscaler
- func CreateContainerResourceHorizontalPodAutoscaler(rc *ResourceConsumer, resourceType v1.ResourceName, ...) *autoscalingv2.HorizontalPodAutoscaler
- func CreateCustomResourceDefinition(c crdclientset.Interface) *apiextensionsv1.CustomResourceDefinition
- func CreateCustomSubresourceInstance(namespace, name string, client dynamic.ResourceInterface, ...) (*unstructured.Unstructured, error)
- func CreateHorizontalPodAutoscaler(rc *ResourceConsumer, targetRef autoscalingv2.CrossVersionObjectReference, ...) *autoscalingv2.HorizontalPodAutoscaler
- func CreateMetricTargetWithType(resourceType v1.ResourceName, targetType autoscalingv2.MetricTargetType, ...) autoscalingv2.MetricTarget
- func CreateResourceHorizontalPodAutoscaler(rc *ResourceConsumer, resourceType v1.ResourceName, ...) *autoscalingv2.HorizontalPodAutoscaler
- func DeleteContainerResourceHPA(rc *ResourceConsumer, autoscalerName string)
- func DeleteHPAWithBehavior(rc *ResourceConsumer, autoscalerName string)
- func DeleteHorizontalPodAutoscaler(rc *ResourceConsumer, autoscalerName string)
- func ExistsInDiscovery(crd *apiextensionsv1.CustomResourceDefinition, ...) (bool, error)
- func HPABehaviorWithScaleDisabled(scalingDirection ScalingDirection) *autoscalingv2.HorizontalPodAutoscalerBehavior
- func HPABehaviorWithScaleLimitedByNumberOfPods(scalingDirection ScalingDirection, numberOfPods, periodSeconds int32) *autoscalingv2.HorizontalPodAutoscalerBehavior
- func HPABehaviorWithScaleLimitedByPercentage(scalingDirection ScalingDirection, percentage, periodSeconds int32) *autoscalingv2.HorizontalPodAutoscalerBehavior
- func HPABehaviorWithScaleUpAndDownRules(scaleUpRule, scaleDownRule *autoscalingv2.HPAScalingRules) *autoscalingv2.HorizontalPodAutoscalerBehavior
- func HPABehaviorWithScalingRuleInDirection(scalingDirection ScalingDirection, rule *autoscalingv2.HPAScalingRules) *autoscalingv2.HorizontalPodAutoscalerBehavior
- func HPABehaviorWithStabilizationWindows(upscaleStabilization, downscaleStabilization time.Duration) *autoscalingv2.HorizontalPodAutoscalerBehavior
- func HPAScalingRuleWithPolicyDisabled() *autoscalingv2.HPAScalingRules
- func HPAScalingRuleWithScalingPolicy(policyType autoscalingv2.HPAScalingPolicyType, value, periodSeconds int32) *autoscalingv2.HPAScalingRules
- func HPAScalingRuleWithStabilizationWindow(stabilizationDuration int32) *autoscalingv2.HPAScalingRules
- type ResourceConsumer
- func (rc *ResourceConsumer) CleanUp()
- func (rc *ResourceConsumer) ConsumeCPU(millicores int)
- func (rc *ResourceConsumer) ConsumeCustomMetric(amount int)
- func (rc *ResourceConsumer) ConsumeMem(megabytes int)
- func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, ...)
- func (rc *ResourceConsumer) GetHpa(name string) (*autoscalingv1.HorizontalPodAutoscaler, error)
- func (rc *ResourceConsumer) GetReplicas() int
- func (rc *ResourceConsumer) Pause()
- func (rc *ResourceConsumer) Resume()
- func (rc *ResourceConsumer) WaitForReplicas(desiredReplicas int, duration time.Duration)
- type ScalingDirection
- type SidecarStatusType
- type SidecarWorkloadType
Constants ¶
This section is empty.
Variables ¶
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"} // KindCRD is the GVK for CRD for test purposes KindCRD = schema.GroupVersionKind{Group: crdGroup, Version: crdVersion, Kind: crdKind} )
Functions ¶
func CreateCPUHorizontalPodAutoscalerWithBehavior ¶ added in v1.24.0
func CreateCPUHorizontalPodAutoscalerWithBehavior(rc *ResourceConsumer, cpu int32, minReplicas int32, maxRepl int32, behavior *autoscalingv2.HorizontalPodAutoscalerBehavior) *autoscalingv2.HorizontalPodAutoscaler
func CreateCPUResourceHorizontalPodAutoscaler ¶ added in v1.26.0
func CreateCPUResourceHorizontalPodAutoscaler(rc *ResourceConsumer, cpu, minReplicas, maxReplicas int32) *autoscalingv2.HorizontalPodAutoscaler
func CreateContainerResourceHorizontalPodAutoscaler ¶ added in v1.26.0
func CreateContainerResourceHorizontalPodAutoscaler(rc *ResourceConsumer, resourceType v1.ResourceName, metricTargetType autoscalingv2.MetricTargetType, metricTargetValue, minReplicas, maxReplicas int32) *autoscalingv2.HorizontalPodAutoscaler
func CreateCustomResourceDefinition ¶ added in v1.26.0
func CreateCustomResourceDefinition(c crdclientset.Interface) *apiextensionsv1.CustomResourceDefinition
func CreateCustomSubresourceInstance ¶ added in v1.26.0
func CreateCustomSubresourceInstance(namespace, name string, client dynamic.ResourceInterface, definition *apiextensionsv1.CustomResourceDefinition) (*unstructured.Unstructured, error)
func CreateHorizontalPodAutoscaler ¶ added in v1.26.0
func CreateHorizontalPodAutoscaler(rc *ResourceConsumer, targetRef autoscalingv2.CrossVersionObjectReference, namespace string, metrics []autoscalingv2.MetricSpec, resourceType v1.ResourceName, metricTargetType autoscalingv2.MetricTargetType, metricTargetValue, minReplicas, maxReplicas int32) *autoscalingv2.HorizontalPodAutoscaler
func CreateMetricTargetWithType ¶ added in v1.26.0
func CreateMetricTargetWithType(resourceType v1.ResourceName, targetType autoscalingv2.MetricTargetType, targetValue int32) autoscalingv2.MetricTarget
func CreateResourceHorizontalPodAutoscaler ¶ added in v1.26.0
func CreateResourceHorizontalPodAutoscaler(rc *ResourceConsumer, resourceType v1.ResourceName, metricTargetType autoscalingv2.MetricTargetType, metricTargetValue, minReplicas, maxReplicas int32) *autoscalingv2.HorizontalPodAutoscaler
func DeleteContainerResourceHPA ¶ added in v1.23.0
func DeleteContainerResourceHPA(rc *ResourceConsumer, autoscalerName string)
DeleteContainerResourceHPA delete the horizontalPodAutoscaler for consuming resources.
func DeleteHPAWithBehavior ¶ added in v1.24.0
func DeleteHPAWithBehavior(rc *ResourceConsumer, autoscalerName string)
func DeleteHorizontalPodAutoscaler ¶
func DeleteHorizontalPodAutoscaler(rc *ResourceConsumer, autoscalerName string)
DeleteHorizontalPodAutoscaler delete the horizontalPodAutoscaler for consuming resources.
func ExistsInDiscovery ¶ added in v1.26.0
func ExistsInDiscovery(crd *apiextensionsv1.CustomResourceDefinition, apiExtensionsClient crdclientset.Interface, version string) (bool, error)
func HPABehaviorWithScaleDisabled ¶ added in v1.25.0
func HPABehaviorWithScaleDisabled(scalingDirection ScalingDirection) *autoscalingv2.HorizontalPodAutoscalerBehavior
func HPABehaviorWithScaleLimitedByNumberOfPods ¶ added in v1.25.0
func HPABehaviorWithScaleLimitedByNumberOfPods(scalingDirection ScalingDirection, numberOfPods, periodSeconds int32) *autoscalingv2.HorizontalPodAutoscalerBehavior
func HPABehaviorWithScaleLimitedByPercentage ¶ added in v1.25.0
func HPABehaviorWithScaleLimitedByPercentage(scalingDirection ScalingDirection, percentage, periodSeconds int32) *autoscalingv2.HorizontalPodAutoscalerBehavior
func HPABehaviorWithScaleUpAndDownRules ¶ added in v1.25.0
func HPABehaviorWithScaleUpAndDownRules(scaleUpRule, scaleDownRule *autoscalingv2.HPAScalingRules) *autoscalingv2.HorizontalPodAutoscalerBehavior
func HPABehaviorWithScalingRuleInDirection ¶ added in v1.25.0
func HPABehaviorWithScalingRuleInDirection(scalingDirection ScalingDirection, rule *autoscalingv2.HPAScalingRules) *autoscalingv2.HorizontalPodAutoscalerBehavior
func HPABehaviorWithStabilizationWindows ¶ added in v1.25.0
func HPABehaviorWithStabilizationWindows(upscaleStabilization, downscaleStabilization time.Duration) *autoscalingv2.HorizontalPodAutoscalerBehavior
func HPAScalingRuleWithPolicyDisabled ¶ added in v1.25.0
func HPAScalingRuleWithPolicyDisabled() *autoscalingv2.HPAScalingRules
func HPAScalingRuleWithScalingPolicy ¶ added in v1.25.0
func HPAScalingRuleWithScalingPolicy(policyType autoscalingv2.HPAScalingPolicyType, value, periodSeconds int32) *autoscalingv2.HPAScalingRules
func HPAScalingRuleWithStabilizationWindow ¶ added in v1.25.0
func HPAScalingRuleWithStabilizationWindow(stabilizationDuration int32) *autoscalingv2.HPAScalingRules
Types ¶
type ResourceConsumer ¶
type ResourceConsumer struct {
// contains filtered or unexported fields
}
ResourceConsumer is a tool for testing. It helps to create a specified usage of CPU or memory. 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 ¶
func (rc *ResourceConsumer) GetHpa(name string) (*autoscalingv1.HorizontalPodAutoscaler, error)
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 ScalingDirection ¶ added in v1.25.0
type ScalingDirection int
ScalingDirection identifies the scale direction for HPA Behavior.
const ( DirectionUnknown ScalingDirection = iota ScaleUpDirection ScaleDownDirection )
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" )