kubernetes/kops · error
can only delete one instance group at a time
Error message
can only delete one instance group at a time
What it means
The Args validator accepts exactly one instance group per invocation. If more than one positional argument is passed, the command refuses with this error; each group must be deleted in a separate command run.
Source
Thrown at cmd/kops/delete_instancegroup.go:82
Aliases: []string{"instancegroups", "ig"},
Short: deleteInstanceGroupShort,
Long: deleteInstanceGroupLong,
Example: deleteInstanceGroupExample,
Args: func(cmd *cobra.Command, args []string) error {
options.ClusterName = rootCommand.ClusterName(true)
if options.ClusterName == "" {
return fmt.Errorf("--name is required")
}
if len(args) == 0 {
return fmt.Errorf("must specify the name of the instance group to delete")
}
options.GroupName = args[0]
if len(args) != 1 {
return fmt.Errorf("can only delete one instance group at a time")
}
return nil
},
ValidArgsFunction: completeInstanceGroup(f, nil, &[]string{kops.InstanceGroupRoleControlPlane.ToLowerString()}),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
if !options.Yes {
message := fmt.Sprintf("Do you really want to delete instance group %q? This action cannot be undone.", options.GroupName)
c := &ui.ConfirmArgs{
Out: out,
Message: message,
Default: "no",
Retries: 2,
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Delete groups one at a time: run the command once per instance group.
- Loop in shell: `for g in groupA groupB; do kops delete instancegroup --name "$CLUSTER" "$g"; done`.
- Quote or disable globs so extra files aren't passed as arguments.
Example fix
// before $ kops delete instancegroup --name prod.example.com workers spot-workers error: can only delete one instance group at a time // after $ kops delete instancegroup --name prod.example.com workers $ kops delete instancegroup --name prod.example.com spot-workers
Defensive patterns
Strategy: validation
Validate before calling
[ $# -eq 1 ] || { echo "pass exactly one instance group" >&2; exit 1; } Prevention
- Loop over groups instead of passing multiple arguments.
- Quote globs ("$@", set -f) to avoid accidental extra positional args.
- Read `kops delete instancegroup --help` to confirm single-argument arity.
When it happens
Trigger: Running `kops delete instancegroup --name <cluster> groupA groupB` or passing extra positional words (e.g. a stray filename from shell glob expansion).
Common situations: Assuming multi-arg support like `kubectl delete` resources; accidental glob expansion (*.yaml matching files); copy-pasting multiple group names from notes.
Related errors
- spec.PublicKey is required
- adding keypair to %q is not supported
- unable to parse YAML %v: %v
- error adding SSH public key: %v
- parsing file %q: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/76f1f228c1024219.
Report an issue: GitHub.