kubernetes/kops · error
must specify the name of the instance group to delete
Error message
must specify the name of the instance group to delete
What it means
The cobra Args validator for `kops delete instancegroup` requires exactly one positional argument: the instance group name. When zero arguments are given, the command aborts with this error before any cluster API interaction.
Source
Thrown at cmd/kops/delete_instancegroup.go:76
func NewCmdDeleteInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command {
options := &DeleteInstanceGroupOptions{}
cmd := &cobra.Command{
Use: "instancegroup INSTANCE_GROUP",
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{View on GitHub (pinned to 4c8573c808)
Solutions
- Provide the group name: `kops delete instancegroup --name <cluster> <group-name>`.
- List available groups first with `kops get instancegroups --name <cluster>` to confirm the exact name.
- Guard the shell variable: `kops delete instancegroup --name "$CLUSTER" "${GROUP:?group not set}"`.
Example fix
// before $ kops delete instancegroup --name prod.example.com error: must specify the name of the instance group to delete // after $ kops delete instancegroup --name prod.example.com workers
Defensive patterns
Strategy: validation
Validate before calling
GROUP="${1:?usage: kops-delete-ig <instance-group>}" Prevention
- Check the group name exists with `kops get instancegroups` before deleting.
- Use ${VAR:?} expansions in scripts so empty variables fail loudly.
- Remember --name is the cluster, not the instance group.
When it happens
Trigger: Running `kops delete instancegroup --name <cluster>` with no instance group name as a positional argument.
Common situations: User forgot the group name expecting a prompt; scripting where a variable holding the group name expanded to empty; confusing --name (cluster) with the instance group argument.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
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/8ccd8b0cea333d04.
Report an issue: GitHub.