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

  1. Provide the group name: `kops delete instancegroup --name <cluster> <group-name>`.
  2. List available groups first with `kops get instancegroups --name <cluster>` to confirm the exact name.
  3. 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

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


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/8ccd8b0cea333d04. Report an issue: GitHub.