kubernetes/kops · error

can only create one instance group at a time

Error message

can only create one instance group at a time

What it means

Argument validation in `kops create instancegroup`: the command only supports creating a single instance group per invocation, so this guard fires when more than one positional argument is passed. Only args[0] is used as the group name; extra arguments are rejected instead of being silently ignored.

Solutions

  1. Pass only one instance group name per command invocation
  2. Create additional instance groups with separate commands
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cmd/kops/create_instancegroup.go:110 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at cmd/kops/create_instancegroup.go:110

		Aliases: []string{"instancegroups", "ig"},
		Short:   createInstanceGroupShort,
		Long:    createInstanceGroupLong,
		Example: createInstanceGroupExample,
		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")
			}

			return nil
		},
		ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
			commandutils.ConfigureKlogForCompletion()
			if len(args) == 1 && rootCommand.ClusterName(false) == "" {
				return []string{"--name"}, cobra.ShellCompDirectiveNoFileComp
			}
			return nil, cobra.ShellCompDirectiveNoFileComp
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			return RunCreateInstanceGroup(cmd.Context(), f, out, options)
		},
	}

	allRoles := make([]string, 0, len(kopsapi.AllInstanceGroupRoles))
	for _, r := range kopsapi.AllInstanceGroupRoles {

View on GitHub (pinned to 4c8573c808)