Horizontal Pod Autoscaler automatically scales the number of pods in a replication controller, deployment or replica set based on observed CPU utilization.
resource "kubernetes_horizontal_pod_autoscaler_v1" "example" {
metadata {
name = "terraform-example"
}
spec {
max_replicas = 10
min_replicas = 8
scale_target_ref {
kind = "Deployment"
name = "MyApp"
}
}
}
The following arguments are supported:
metadata
- (Required) Standard horizontal pod autoscaler's metadata. For more info see Kubernetes referencespec
- (Required) Behaviour of the autoscaler. For more info see Kubernetes referencemetadata
annotations
- (Optional) An unstructured key value map stored with the horizontal pod autoscaler that may be used to store arbitrary metadata.generate_name
- (Optional) Prefix, used by the server, to generate a unique name ONLY IF the name
field has not been provided. This value will also be combined with a unique suffix. For more info see Kubernetes referencelabels
- (Optional) Map of string keys and values that can be used to organize and categorize (scope and select) the horizontal pod autoscaler. May match selectors of replication controllers and services.name
- (Optional) Name of the horizontal pod autoscaler, must be unique. Cannot be updated. For more info see Kubernetes referencenamespace
- (Optional) Namespace defines the space within which name of the horizontal pod autoscaler must be unique.generation
- A sequence number representing a specific generation of the desired state.resource_version
- An opaque value that represents the internal version of this horizontal pod autoscaler that can be used by clients to determine when horizontal pod autoscaler has changed. For more info see Kubernetes referenceuid
- The unique in time and space value for this horizontal pod autoscaler. For more info see Kubernetes referencespec
max_replicas
- (Required) Upper limit for the number of pods that can be set by the autoscaler.min_replicas
- (Optional) Lower limit for the number of pods that can be set by the autoscaler, defaults to 1
.scale_target_ref
- (Required) Reference to scaled resource. e.g. Replication Controllertarget_cpu_utilization_percentage
- (Optional) Target average CPU utilization (represented as a percentage of requested CPU) over all the pods. If not specified the default autoscaling policy will be used.scale_target_ref
api_version
- (Optional) API version of the referent. This argument is optional for the v1
API version referents and mandatory for the rest.kind
- (Required) Kind of the referent. e.g. ReplicationController
. For more info see Kubernetes referencename
- (Required) Name of the referent. For more info see Kubernetes referenceHorizontal Pod Autoscaler can be imported using the namespace and name, e.g.
$ terraform import kubernetes_horizontal_pod_autoscaler_v1.example default/terraform-example