Remove specific nodes

If you need to remove specific machines from your cluster, you can do so by annotating the Machine object. Just remember to only annotate the Cluster API's Machine object, not HCloudMachine or HetznerBareMetalMachine objects.

To annotate the Cluster API's Machine object, select the machines you want to delete and add the "cluster.x-k8s.io/delete-machine"="" annotation. This can be done with kubectl:

For both Hetzner Cloud servers and Hetzner baremetal servers, you'll need to update the replicas in your Cluster resource under spec.topology.workers . This can be done using kubectl edit. Here's an example of how to modify the replicas to scale down the number of Hetzner Cloud servers acting as workload nodes:

yaml
- class: workeramd64hcloud name: md-0 replicas: 5 // [!code --] replicas: 3 // [!code ++]

When you reduce the replicas of the workeramd64hcloud class, the annotated Machines are prioritized for removal, along with the associated HCloudMachine. If there are still machines to be removed after all the annotated machines have been deleted, the controller will randomly select a machines to remove.

Similarly, for HetznerBareMetalMachine and KubeadmControlPlane objects, you'll need to decrease the number of replicas from the corresponding class. For example, to downscale bare metal servers, decrease the number of replicas in the following block:

yaml
- class: workeramd64baremetal metadata: {} name: md-1 replicas: 3 // [!code --] replicas: 2 // [!code ++]

Once the Machines are deleted, the nodes will also be removed from the workload cluster.

Previous
Labelling and assign roles on nodes
Next
Using ARM servers