Question

Difficulty: MediumManaging Google Kubernetes Engine Resources

A cloud operations engineer needs to safely isolate a malfunctioning node in a Google Kubernetes Engine (GKE) cluster for maintenance while ensuring high application availability. In which correct sequential order should the engineer execute these operational steps?

  1. 1Execute `kubectl cordon <node-name>` to mark the target node as unschedulable.
  2. 2Execute `kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data` to evict existing pods.
  3. 3Execute `kubectl get pods -o wide` to verify all evicted workloads are running on remaining healthy nodes.
  4. 4Delete or reset the underlying Compute Engine VM instance using `gcloud compute instances delete`.

Answer

The correct sequence is to first mark the node unschedulable (`kubectl cordon`), then gracefully evict workloads (`kubectl drain`), next verify that evicted pods are healthy on remaining cluster nodes (`kubectl get pods`), and finally perform maintenance or deletion on the underlying VM instance (`gcloud compute instances delete`).
Cordoning must be performed first to set the node to unschedulable state, preventing Kubernetes from scheduling new pods onto it during maintenance. Next, draining evicts existing non-DaemonSet workloads so they can be recreated on other healthy nodes. After draining, engineers must verify that all pods have resumed normal execution on alternative nodes before taking destructive or maintenance actions against the underlying VM instance.

Step-by-Step Solution

1
Run `kubectl cordon <node-name>`
The target node status changes to `SchedulingDisabled`.
This prevents new pods from being scheduled onto the node while preparing for eviction.
2
Run `kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data`
Running pods are evicted and rescheduled on remaining healthy nodes in the cluster.
This gracefully vacates the node without causing unnecessary workload disruption.
3
Run `kubectl get pods -o wide`
Confirms all application replicas have transitioned to `Running` state on active nodes.
Ensures service availability before taking the host node offline.
4
Execute maintenance or delete the VM via `gcloud compute instances delete`
The physical/virtual node instance is safely removed or rebooted.
Node maintenance can now take place without impacting running applications.

Key Concept

GKE Node Maintenance and Pod Eviction Sequence
Estimated Time:1m 30s
Rate this question