kubernetes/kops · error

must specify name of instance group to create

Error message

must specify name of instance group to create

What it means

The command creates exactly one instance group whose name is given as the single positional argument. If no positional argument is supplied, Args validation returns this error telling the user to name the instance group to create.

Source

Thrown at cmd/kops/toolbox_instance-selector.go:130

func NewCmdToolboxInstanceSelector(f commandutils.Factory, out io.Writer) *cobra.Command {
	options := &InstanceSelectorOptions{}

	commandline := cli.New(
		"instance-selector INSTANCE_GROUP",
		toolboxInstanceSelectorShort,
		toolboxInstanceSelectorLong,
		toolboxInstanceSelectorExample,
		nil,
	)
	commandline.Command.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 name of instance group to create")
		}

		options.InstanceGroupName = args[0]

		if len(args) != 1 {
			return fmt.Errorf("can only create one instance group at a time")
		}

		if err := processAndValidateFlags(&commandline); err != nil {
			return err
		}
		setInstanceSelectorOpts(options, &commandline)

		return nil
	}
	commandline.Command.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		commandutils.ConfigureKlogForCompletion()
		if len(args) == 1 && rootCommand.ClusterName(false) == "" {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Supply the instance group name: kops toolbox instance-selector nodes --name <cluster>
  2. If you only want recommendations, check flags like --dry-run if available instead of omitting the name

Example fix

// before
kops toolbox instance-selector --name mycluster.k8s.local
// after
kops toolbox instance-selector nodes --name mycluster.k8s.local
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$IG" ]; then
  echo "usage: kops toolbox instance-selector <instance-group-name> --name <cluster>" >&2
  exit 2
fi

Prevention

When it happens

Trigger: Running `kops toolbox instance-selector --name <cluster>` with no instance-group name argument.

Common situations: Assuming the tool only prints recommendations (without creating) and omitting the name; copy-pasting flag examples without the positional arg; wrapping scripts that drop args.

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/db6d79ef677e2079. Report an issue: GitHub.