Skip to content

K8s HPA

udx-github edited this page Jul 3, 2026 · 3 revisions

Creates a Kubernetes HorizontalPodAutoscaler from a native manifest definition.

Use this module when a Rabbit service needs automatic pod scaling based on CPU, memory, or custom metrics.

Supported Features

  • HPA creation from a standard Kubernetes manifest.
  • Configurable min and max replicas.
  • Resource-based metrics (CPU, memory) with target utilization.
  • Scale target reference to Deployments or other workloads.

Prerequisites

  • A kubeconfig secret created by the k8s-access module.
  • The target namespace and Deployment must exist.
  • The horizontal_pod_autoscaling addon must be enabled on the GKE cluster.

Important Notes

  • The configurations key accepts a complete Kubernetes HPA manifest (without apiVersion and kind).
  • scaleTargetRef must reference an existing workload in the same namespace.
  • minReplicas defaults to 1 when not specified.

Minimal Example

services:
  - name: "k8s HPA"
    module: "k8s-hpa"
    id: "app-hpa"
    deployment_order: 110
    configurations:
      metadata:
        name: "www-example-com"
        namespace: "www-example-com"
      spec:
        minReplicas: 1
        maxReplicas: 5
        scaleTargetRef:
          apiVersion: "apps/v1"
          kind: "Deployment"
          name: "www-example-com"
        metrics:
          - type: "Resource"
            resource:
              name: "cpu"
              target:
                type: "Utilization"
                averageUtilization: 70

Outputs

This module does not produce outputs.

Full Configuration Schema

The configurations key accepts a native Kubernetes HPA manifest body. See the Kubernetes HPA spec for the full schema.

configurations:
  metadata:
    name: ""
    namespace: ""
    labels: {}
    annotations: {}
  spec:
    minReplicas: 1
    maxReplicas: 5
    scaleTargetRef:
      apiVersion: "apps/v1"
      kind: "Deployment"
      name: ""
    metrics:
      - type: "Resource"
        resource:
          name: "cpu"
          target:
            type: "Utilization"
            averageUtilization: 70

Clone this wiki locally