无法删除Kubernetes中节点的基础VM

时间:2017-03-29 13:48:38

标签: kubernetes google-compute-engine google-kubernetes-engine

我正在GCE上运行三节点集群。我想要耗尽一个节点并删除底层VM。

kubectl drain命令的文档说:

Once it returns (without giving an error), you can power down the node (or equivalently, if on a cloud platform, delete the virtual machine backing the node)

我执行以下命令:

  1. 获取节点

    $ kl get nodes
    NAME                                      STATUS    AGE
    gke-jcluster-default-pool-9cc4e660-6q21   Ready     43m
    gke-jcluster-default-pool-9cc4e660-rx9p   Ready     6m
    gke-jcluster-default-pool-9cc4e660-xr4z   Ready     23h
    
  2. 排空节点rx9p

    $ kl drain gke-jcluster-default-pool-9cc4e660-rx9p --force
    node "gke-jcluster-default-pool-9cc4e660-rx9p" cordoned
    WARNING: Deleting pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet: fluentd-cloud-logging-gke-jcluster-default-pool-9cc4e660-rx9p, kube-proxy-gke-jcluster-default-pool-9cc4e660-rx9p
    node "gke-jcluster-default-pool-9cc4e660-rx9p" drained
    
  3. 删除gcloud VM。

     $ gcloud compute instances delete gke-jcluster-default-pool-9cc4e660-rx9p
    
  4. 列出虚拟机。

     $ gcloud compute instances list
    

    在结果中,我看到上面删除的VM - rx9p。如果我kubectl get nodes,我也会看到rx9p节点。

  5. 发生了什么事?有什么东西正在重新启动我要删除的VM?我是否必须等待命令之间的超时?

1 个答案:

答案 0 :(得分:4)

您正走在正确的轨道上,首先耗尽节点。

节点(计算实例)是managed instance group的一部分。如果仅使用gcloud compute instances delete命令删除它们,则托管实例组将重新创建它们。

要正确删除一个,请使用此命令(在耗尽之后!):

gcloud compute instance-groups managed delete-instances \
  gke-jcluster-default-pool-9cc4e660-grp \
  --instances=gke-jcluster-default-pool-9cc4e660-rx9p \
  --zone=...