Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't delete underlying VM for a node in Kubernetes

I'm running a three node cluster on GCE. I want to drain one node and delete the underlying VM.

Documentation for kubectl drain command says:

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)

I execute the following commands:

  1. Get the nodes

    $ 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. Drain node 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. Delete gcloud VM.

     $ gcloud compute instances delete gke-jcluster-default-pool-9cc4e660-rx9p
    
  4. List VMs.

     $ gcloud compute instances list
    

    In the result, I'm seeing the VM I deleted above - rx9p. If I do kubectl get nodes, I'm seeing the rx9p node too.

What's going on? Something is restarting the VM I'm deleting? Do I have to wait for some timeout between the commands?

like image 854
Petko M Avatar asked Mar 29 '17 13:03

Petko M


People also ask

How do I delete a virtual service in Kubernetes?

You can delete a StatefulSet in the same way you delete other resources in Kubernetes: use the kubectl delete command, and specify the StatefulSet either by file or by name. You may need to delete the associated headless service separately after the StatefulSet itself is deleted.

How do you force delete a namespace in Kubernetes?

To force delete a Kubernetes namespace, remove the finalizer from the namespace's configuration. The finalizer is a Kubernetes resource whose purpose is to prohibit the force removal of an object.

How do I delete a node in Kubernetes?

To remove a Kubernetes Node:Log in to the Kubernetes Node that you want to remove. Log in to the Salt Master node. Log in to any Kubernetes Master node. Wait until the workloads are gracefully deleted and the Kubernetes Node is removed.

How do you delete a node pool?

In the cluster list, select the name of the cluster, and then select View details in the side panel. Select the Nodes tab to see a list of all the node pools. Select a node pool from the list. Near the top of the window, click delete Delete.


1 Answers

You are on the right track with draining the node first.

The nodes (compute instances) are part of a managed instance group. If you delete just them with the gcloud compute instances delete command the managed instance group will recreate them.

To delete one properly use this command (after you have drained it!):

gcloud compute instance-groups managed delete-instances \
  gke-jcluster-default-pool-9cc4e660-grp \
  --instances=gke-jcluster-default-pool-9cc4e660-rx9p \
  --zone=...
like image 134
Janos Lenart Avatar answered Sep 30 '22 04:09

Janos Lenart