kubernetes/kops · error
cannot delete the only control plane instance group
Error message
cannot delete the only control plane instance group
What it means
Safety guard: kOps refuses to delete the only instance group with a control-plane role, since that would leave the cluster without a control plane and unrecoverable. The check runs only when the target group has the control-plane role and no other control-plane group exists.
Source
Thrown at cmd/kops/delete_instancegroup.go:165
fmt.Fprintf(out, "InstanceGroup %q found for deletion\n", groupName)
if group.Spec.Role.HasControlPlane() {
groups, err := clientset.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})
if err != nil {
return fmt.Errorf("listing InstanceGroups: %v", err)
}
onlyMaster := true
for _, ig := range groups.Items {
if ig.Name != groupName && ig.Spec.Role.HasControlPlane() {
onlyMaster = false
break
}
}
if onlyMaster {
return fmt.Errorf("cannot delete the only control plane instance group")
}
}
if !options.Yes {
fmt.Fprintf(out, "\nMust specify --yes to delete instancegroup\n")
return nil
}
cloud, err := cloudup.BuildCloud(cluster)
if err != nil {
return err
}
d := &instancegroups.DeleteInstanceGroup{}
d.Cluster = cluster
d.Cloud = cloud
d.Clientset = clientset
View on GitHub (pinned to 4c8573c808)
Solutions
- Create a second control-plane instance group first (kops create instancegroup with role Master), update the cluster, then delete the old one
- If you intend to remove the cluster entirely, use `kops delete cluster` instead
- Add another master node group via `kops create ig` and `kops update cluster --yes` before deleting
Example fix
// before kops delete instancegroup master-us-east-1a --yes // after: add a replacement control-plane IG first kops create instancegroup master-us-east-1b --role Master --name mycluster.k8s.local kops update cluster --yes kops delete instancegroup master-us-east-1a --yes
Defensive patterns
Strategy: validation
Validate before calling
igs, _ := clientset.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})
cpCount := 0
for _, ig := range igs.Items {
if ig.Spec.Role.HasControlPlane() { cpCount++ }
}
// proceed with delete only if cpCount > 1 and target is control-plane Prevention
- Never delete a control-plane group unless at least one other exists
- Use `kops get instancegroups` and check roles before --yes
- Prefer `kops delete cluster` when dismantling the whole cluster
- Add a replacement Master-role IG and run `kops update cluster --yes` before removing an old one
When it happens
Trigger: Running `kops delete instancegroup <name> --yes` where <name> is the sole instance group whose Spec.Role.HasControlPlane() is true.
Common situations: Trying to tear down just the masters to rebuild them; cleaning up a single-master cluster by deleting its control-plane group instead of deleting the whole cluster.
Related errors
- Error too many '=' (%d) in %s
- at least one channel URL is required
- building menu for %q: %w
- applying %q: %w
- unable to parse argument %q as url
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/51216437e87f2e9c.
Report an issue: GitHub.