Skip to content

Commit

Permalink
add support for node scale request
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch committed Apr 14, 2024
1 parent d70c9f9 commit 4cb539c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions kubescaler/scaler/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,30 @@ def get_cluster(self, node_pools=None, scaling_profile=None):
print(cluster)
return cluster

@timed
def update_cluster(self, size, max_nodes, min_nodes):
"""
Update a cluster. Currently we support the max and min size
"""
autoscaling = container_v1.NodePoolAutoscaling(
enabled=True,
total_max_node_count=max_nodes,
total_min_node_count=min_nodes,
)
request = container_v1.SetNodePoolAutoscalingRequest(
autoscaling=autoscaling,
name=f"projects/{self.project}/locations/{self.location}/clusters/{self.name}/nodePools/{self.default_pool}",
)
print("\n🥣️ cluster node pool update request")
print(request)

response = self.client.set_node_pool_autoscaling(request=request)
print(response)

# Status 2 is running (1 is provisioning)
print(f"⏱️ Waiting for {self.cluster_name} to be ready...")
return self.wait_for_status(2)

@timed
def create_cluster(self):
"""
Expand Down

0 comments on commit 4cb539c

Please sign in to comment.