HorizontalPodAutoscaler
An autoscaler for a Kubernetes service.
NOTE: HorizontalPodAutoscaler is still in beta and is subject to change.
Example usage
1import launchflow as lf
2
3cluster = lf.gcp.GKECluster("my-cluster")
4service = lf.gcp.GKEService(
5 "my-service",
6 cluster=cluster,
7 container_resources=lf.kubernetes.service.ContainerResources(
8 requests=lf.kubernetes.service.ResourceQuantity(cpu="0.2"),
9 ),
10)
11hpa = lf.kubernetes.HorizontalPodAutoscaler(
12 "hpa",
13 cluster=cluster,
14 target_name=service.name
15)
initialization
Create a new HorizontalPodAutoscaler.
Args:
name (str)
: The name of the resource.cluster (GKECluster)
: The cluster to create the resource in.target_name (str)
: The name of the target deployment.namespace (str)
: The namespace to create the resource in. Default is "default".min_replicas (int)
: The minimum number of replicas. Default is 1.max_replicas (int)
: The maximum number of replicas. Default is 10.resource_metrics (List[ResourceMetric])
: List ResourceMetrics to use for scaling. Default is CPU utilization at 60%.