kubernetes_horizontal_pod_autoscaler_v2beta2

Horizontal Pod Autoscaler automatically scales the number of pods in a replication controller, deployment or replica set based on observed CPU utilization.

Example Usage, with metric

resource "kubernetes_horizontal_pod_autoscaler_v2beta2" "example" {
  metadata {
    name = "test"
  }

  spec {
    min_replicas = 50
    max_replicas = 100

    scale_target_ref {
      kind = "Deployment"
      name = "MyApp"
    }

    metric {
      type = "External"
      external {
        metric {
          name = "latency"
          selector {
            match_labels = {
              lb_name = "test"
            }
          }
        }
        target {
          type  = "Value"
          value = "100"
        }
      }
    }
  }
}

Example Usage, with behavior

resource "kubernetes_horizontal_pod_autoscaler_v2beta2" "example" {
  metadata {
    name = "test"
  }

  spec {
    min_replicas = 50
    max_replicas = 100

    scale_target_ref {
      kind = "Deployment"
      name = "MyApp"
    }

    behavior {
      scale_down {
        stabilization_window_seconds = 300
        select_policy                = "Min"
        policy {
          period_seconds = 120
          type           = "Pods"
          value          = 1
        }

        policy {
          period_seconds = 310
          type           = "Percent"
          value          = 100
        }
      }
      scale_up {
        stabilization_window_seconds = 600
        select_policy                = "Max"
        policy {
          period_seconds = 180
          type           = "Percent"
          value          = 100
        }
        policy {
          period_seconds = 600
          type           = "Pods"
          value          = 5
        }
      }
    }
  }
}

Argument Reference

The following arguments are supported:

Nested Blocks

metadata

Arguments

Attributes

spec

Arguments

metric

Arguments

Metric Type: container_resource

Arguments

Metric Type: external

Arguments

Metric Type: object

Arguments

Metric Type: pods

Arguments

Metric Type: resource

Arguments

metric

Arguments

target

Arguments

Quantities

See here for documentation on resource management for pods and containers.

described_object

Arguments

scale_target_ref

Arguments

behavior

Arguments

scale_up

Arguments

policy

Arguments

Import

Horizontal Pod Autoscaler can be imported using the namespace and name, e.g.

$ terraform import kubernetes_horizontal_pod_autoscaler_v2beta2.example default/terraform-example