You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何缩减Kubernetes集群Minion节点?执行操作后节点仍自动重建

Ah, I've run into this exact issue with GCE Kubernetes clusters before! The problem here is that your minion nodes are managed by a Managed Instance Group (MIG) on GCP, which is configured to maintain a fixed number of healthy nodes at all times. That's why deleting nodes manually or via kubectl delete node just makes the MIG spin up replacements right away.

Here's the step-by-step fix to properly scale down your cluster without nodes coming back:

1. Adjust the desired node count in your Managed Instance Group

You need to tell GCP to reduce the number of nodes it should maintain first. You can do this either via the gcloud CLI or the GCP Console:

  • Using gcloud CLI:
    First, find the name of your minion instance group (it typically looks like kubernetes-minion-group-<your-cluster-name>):
    gcloud compute instance-groups list
    
    Then set your new desired node count:
    gcloud compute instance-groups managed set-size <your-minion-instance-group> --size <new-node-count>
    
  • Using GCP Console:
    Navigate to Compute Engine > Instance groups, select your minion group, edit the "Number of instances" field to your target count, and save the changes.

2. Safely drain and remove excess nodes

Once the MIG knows to maintain fewer nodes, you need to evict pods from the nodes you want to remove and clean them up in Kubernetes:

  • Drain the node to evict all non-daemonset pods (daemonsets are meant to run on every node, so we skip them):
    kubectl drain <node-name> --ignore-daemonsets
    
  • Delete the node from Kubernetes:
    kubectl delete node <node-name>
    
    The MIG will automatically terminate the corresponding VM instance once it's marked for deletion, or you can let the MIG handle the cleanup based on the new size you set.

Alternative: Use the kube-up.sh script (if you used it for deployment)

If you originally set up your cluster with the kube-up.sh script, you can re-run it with the NUM_NODES environment variable to adjust the count in one go:

NUM_NODES=<new-node-count> ./kube-up.sh

This will automatically adjust the MIG size, drain excess nodes, and clean up Kubernetes node entries for you—no manual steps needed.

Just remember: never delete VM instances directly when they're part of a managed instance group. The MIG will always replace them to meet the desired node count. Always adjust the MIG size first, then handle the Kubernetes node cleanup.

内容的提问来源于stack exchange,提问作者maxadorable

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:52:24