Skip to content

Commit

Permalink
Enhance ack.sh auto-scaling logic by adding detailed comments to clar…
Browse files Browse the repository at this point in the history
…ify the scaling process. The new comments explain the rationale for incrementing the pod count during scaling up and the gradual decrement during scaling down, ensuring better resource management and preventing unnecessary scaling to virtual nodes. This update improves the understanding of the operational intent behind the scaling actions.
  • Loading branch information
xiagw committed Jan 13, 2025
1 parent de534e0 commit 980d66f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/aliyun/ack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ ack_auto_scale() {
# 检查是否需要扩容
if ((cpu > pod_cpu_warn && mem > pod_mem_warn)); then
kubectl -n "$namespace" top pod -l "app.kubernetes.io/name=$deployment"
## 扩容数量每次增加2,应对突发流量
scale_deployment "up" $((pod_total + SCALE_CHANGE)) "$lock_file_up"
return
fi
Expand All @@ -568,10 +569,11 @@ ack_auto_scale() {
if ((cpu < pod_cpu_normal && mem < pod_mem_normal)); then
if ((pod_total > node_fixed)); then
kubectl -n "$namespace" top pod -l "app.kubernetes.io/name=$deployment"
## workloadspread 已经设置最大pod数量为ECS节点池中节点的数量,
## 当执行 helm 部署时,pod数量超过节点数量,会自动扩容到虚拟节点
## 为了避免扩容到虚拟节点,所以这里需要缩容到ECS节点池中节点的数量减1,
scale_deployment "down" $((node_fixed - 1)) "$lock_file_down"
## 1,已经配置了 workloadspread ,且已经设置最大pod数量为ECS节点池中节点的数量,
## 2,当执行 helm 部署时,pod数量超过节点数量,会自动扩容到虚拟节点,但是不希望helm部署到虚拟节点,
## 3,为了避免扩容到虚拟节点,所以这里需要缩容到ECS节点池中节点的数量少1个,
## 4,缩容时不要骤减pod数量,所以这里需要缩容数量逐步减1,
scale_deployment "down" $((pod_total - SCALE_CHANGE)) "$lock_file_down"
return
fi
## 检查是否有pod运行在虚拟节点,如果有则执行 kubectl rollout restart 命令
Expand Down

0 comments on commit 980d66f

Please sign in to comment.