Skip to content
Proud to collaborate with Microsoft for Startups

kubernetes.horizontalpodautoscaler.ensure ​

Create or replace a namespaced Kubernetes HorizontalPodAutoscaler (autoscaling/v2)

Creates a HorizontalPodAutoscaler in the given namespace; replaces it in full if it already exists. Accepts a pre-built hpa_spec dict matching the Kubernetes V2HorizontalPodAutoscalerSpec schema (autoscaling/v2).

An HPA and a hardcoded replicas on the target Deployment fight each other: whichever wrote last wins, so a provisioner that re-applies a Deployment spec carrying replicas will repeatedly undo the autoscaler. Once a workload is autoscaled, its Deployment spec should omit replicas entirely.

CPU and memory targets need the metrics API on the cluster (metrics-server, or the managed equivalent). Without it the HPA is created successfully but never scales, reporting unknown for its current metrics — a silent failure that looks like a working autoscaler until load arrives.

Inputs:

  • connection_uuid: Cloud connection UUID (required)
  • namespace: Target namespace (required)
  • name: HorizontalPodAutoscaler name (required)
  • hpa_spec: Full V2HorizontalPodAutoscalerSpec dict (required). Supports scaleTargetRef, minReplicas, maxReplicas, metrics, and behavior.
  • labels: Optional dict of metadata labels set on the object.

Outputs:

  • existed: True if an existing HPA was replaced, False if created.

Plugin required: context.get_plugin("connection").kubernetes_runner_clients(connection_uuid, organization_uuid) must expose autoscaling_v2 — available from ltinteg-cloud-connections with the storage/policy/autoscaling clients.

Overview ​

PropertyValue
Workflow typeAtomic
LibraryApp-kubernetes
Version1.0

Input Schema ​

FieldTypeRequiredDefaultDescription
connection_uuiduuidYes——
namespacestringYes——
namestringYes——
hpa_specjsonYes——
labelsjsonNo——
workflow_run_idstringNo—Engine workflow run id for DAG step execution
organization_uuiduuidNo——

Output Schema ​

FieldTypeRequiredDefaultDescription
connection_uuiduuidNo——
organization_uuiduuidNo——
namespacestringNo——
namestringNo——
hpa_specjsonNo——
labelsjsonNo——
existedbooleanNo——
workflow_run_idstringNo—Engine workflow run id for DAG step execution
failure_reasonstringNo——
failure_typestringNo——
failed_actionstringNo——
failed_at_statestringNo——
failed_stepstringNo——
failed_layerstringNo——
errorstringNo——
error_typestringNo——

States ​

StateInitialTerminalSuccessAuto-advanceDescription
pendingYesNo—execute—
completedNoYesYes——
failedNoYesNo——

State Diagram ​

Transitions ​

FromActionToDescription
pendingexecutecompleted—
* (any state)failfailed—

API Usage ​

bash
POST /api/workflows/start
Content-Type: application/json

{
  "workflow_type": "kubernetes.horizontalpodautoscaler.ensure",
  "initial_data": {
    "connection_uuid": "value",
    "namespace": "value",
    "name": "value",
    "hpa_spec": "value"
  }
}