Documentation
¶
Overview ¶
pkg/resources/hpas/hpa.go
pkg/resources/hpas/types.go
Index ¶
- func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- type ResolvedHPASpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedHPASpec) error
Create creates an HPA owned by the CR if it does not already exist. Idempotent — if the HPA exists, does nothing and returns nil.
func Delete ¶
func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedHPASpec) error
Delete deletes the HPA if it exists.
func DeleteIfOwned ¶
func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, name, namespace string) error
DeleteIfOwned deletes the HPA if it exists and is owned by the CR.
func Update ¶
func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedHPASpec) error
Update reconciles an existing HPA to match the resolved spec. Patches min/max replicas and CPU target when drift is detected. If the HPA does not exist, creates it.
Types ¶
type ResolvedHPASpec ¶
type ResolvedHPASpec struct {
// Name — HPA resource name. Required.
Name string
// Namespace — target namespace.
Namespace string
// ScaleTargetRef — the target workload this HPA scales.
// Supports Deployment, ReplicaSet, StatefulSet, or any scalable resource.
ScaleTargetRef orktypes.ScaleTargetRef
// MinReplicas — minimum pod replica count. Default: 1.
MinReplicas int32
// MaxReplicas — maximum pod replica count. Required.
MaxReplicas int32
// TargetCPUUtilizationPercentage — CPU utilization target (0-100).
// When 0, no CPU metric is configured.
TargetCPUUtilizationPercentage int32
// Labels applied to HPA metadata.
// Orkestra always adds: managed-by=orkestra, orkestra-owner=<cr-name>
Labels map[string]string
// Behavior — fully resolved scaling behavior. nil means use Kubernetes defaults.
// When behavior.profile was declared, it is expanded here at resolve time.
Behavior *orktypes.HPABehavior
// Sleep injects an artificial delay into the reconcile of this resource.
// Useful for autoscale testing, latency simulation, and chaos engineering.
// Accepts extended duration units (s, m, h, d, w, mo, y).
Sleep string
}
ResolvedHPASpec is the fully resolved HorizontalPodAutoscaler specification. All template expressions have been evaluated before this struct is populated. Passed directly to Create, Update, and Delete.
func Resolve ¶
func Resolve(src orktypes.HPATemplateSource, ownerName string, reg orktypes.ProfileRegistry) ResolvedHPASpec
Resolve builds a ResolvedHPASpec from an HPATemplateSource. All template expressions must be evaluated before calling here.