Remove worker nodes from a Kubernetes cluster that the installer created by lowering the worker count in bootstrap.env and running the scale-workers phase, which drains each node before it destroys the server.
Before you start, meet the following requirements:
The installer created the cluster with DEPLOY_INFRA set to true.
You run the installer from the working folder that created the cluster, which holds bootstrap.env and the .kubernetes-install folder.
INFRA_TERRAFORM_VARS_FILE is empty.
The installer image contains the scale-workers phase.
The phase removes the highest-numbered workers, and you cannot choose a different worker. At least one worker always remains, so a value of INFRA_WORKER_COUNT below 1 is refused, and a cluster with a single worker cannot be scaled down. To remove the last worker, destroy the cluster.
Lower the worker count in bootstrap.env, for example, from 3 to 1.
INFRA_WORKER_COUNT="1"
In this example, the phase removes worker-3 and worker-2.
List the Pods that run on each node that the phase removes.
kubectl --kubeconfig .kubernetes-install/kubeconfig get pods -A -o wide \
--field-selector spec.nodeName=<node-name>
List the PodDisruptionBudgets that can block the drain.
kubectl --kubeconfig .kubernetes-install/kubeconfig get pdb -A
The phase lists the workers that it removes and asks for confirmation. In a non-interactive run, add the --yes option, because the phase refuses to remove workers without a confirmation.
Confirm the removal when the phase prompts you.
You do not need to drain the nodes yourself. For each node, the phase drains the node, deletes the node from Kubernetes, and only then destroys the server with Terraform. The drain is graceful, so a PodDisruptionBudget or a Pod that cannot be rescheduled stops the run before the phase destroys anything.
Verify that the removed nodes are gone and that their Pods run on the remaining workers.
kubectl --kubeconfig .kubernetes-install/kubeconfig get nodes
kubectl --kubeconfig .kubernetes-install/kubeconfig get pods -A -o wide
Optional: On a cluster that has Cloudera Cloud Factory installed, verify that every PersistentVolumeClaim is Bound and that all Pods are Running.
kubectl --kubeconfig .kubernetes-install/kubeconfig get pvc -A
kubectl --kubeconfig .kubernetes-install/kubeconfig get pods -A
The cluster has the number of workers that INFRA_WORKER_COUNT specifies, and nodes.json no longer lists the removed workers. The numbers of the removed workers are not reused.