Skip to content

CKS: removeNodesFromKubernetesCluster accepts control, etcd and other clusters' nodes #14801

Open

Description

@bhouse-nexthop

problem

removeNodesFromKubernetesCluster does not check that the node ids belong to the cluster, or that they are nodes added with addNodesToKubernetesCluster. It only checks that each VM exists and that the caller can operate on it. Every id is handed to the remove worker, which:

  • drains and deletes the node from Kubernetes (by VM display name)
  • runs the remove script with kubeadm reset on the VM, if it has a port forwarding rule on port 22 from 2222 up
  • revokes the VM's port forwarding and firewall rules
  • lowers the cluster's node count, memory and cores

What happens for each kind of id:

id passed result
VM in no cluster processed, node count lowered
VM of another cluster processed, that cluster's SSH rules for the VM revoked
control node of this cluster drained, reset, SSH rule revoked
etcd node processed
CKS-managed worker reset and detached but VM left running, node count lowered
node added with addNodesToKubernetesCluster removed (expected)

The command doc says it "Removes external nodes from a CKS cluster", and the UI only lists external nodes, but the API does not enforce this. The command also doesn't check isCommandSupported, so it runs on ExternalManaged clusters too.

versions

4.21.0 and later (4.22 branch, main)

The steps to reproduce the bug

  1. Create a CKS cluster.
  2. Call removeNodesFromKubernetesCluster id=<cluster> nodeids=<control node VM id>.
  3. The control node is drained and reset, and its SSH port forwarding rule is revoked.

What to do about it?

Reject the request with a clear parameter error naming the VM unless each id is a kubernetes_cluster_vm_map row of this cluster with external_node set and neither control_node nor etcd_node set. Also reject the command on cluster types that don't support it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions