hpa

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeploymentReplicas

func DeploymentReplicas(owner Owner, existing *appsv1.Deployment) *int32

DeploymentReplicas returns the spec.replicas to apply to a Deployment owned by owner. It can be used to determine initial replica count for the Deployment, when existing is nil.

func DesiredDeploymentReplicas

func DesiredDeploymentReplicas(
	ctx context.Context,
	cl client.Reader,
	owner Owner,
	key client.ObjectKey,
) (*int32, error)

DesiredDeploymentReplicas returns the spec.replicas to apply to the Deployment owned by owner and identified by key. When owner is horizontally scaled, the Deployment is fetched from cluster and actual value is used. Once spec.replicas has been set through the scale subresource (i.e. by the HPA), nil is returned: spec.replicas must then be left out of the applied configuration, so that the HPA scale is never reverted. The scale took ownership of the field away from other field managers, so leaving it out does not remove it. The exception is a Deployment scaled to 0 (e.g. with kubectl scale): the HPA does not scale a target at 0 replicas, so it is scaled back up, see DeploymentReplicas.

func Ensure

func Ensure(
	ctx context.Context,
	cl client.Client,
	logger logr.Logger,
	owner Owner,
	deploymentName string,
) (op.Result, error)

Ensure reconciles the HorizontalPodAutoscaler owned by owner that targets the Deployment named deploymentName. If owner has no horizontal scaling configured, any existing HPAs owned by owner are deleted.

Types

type Owner

type Owner interface {
	client.Object
	// GetReplicas returns the static replica count, or nil when it is not set.
	// It is ignored when horizontal scaling is configured.
	GetReplicas() *int32
	// GetHorizontalScaling returns the horizontal scaling options, or nil when
	// horizontal scaling is not configured.
	GetHorizontalScaling() *commonv1alpha1.HorizontalScaling
}

Owner is an object that owns a Deployment which can be horizontally scaled by a HorizontalPodAutoscaler.

Jump to

Keyboard shortcuts

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