kubernetes/kops · error
--name is required
Error message
--name is required
What it means
`kops delete instancegroup` validates its arguments in cobra's Args function before running. If rootCommand.ClusterName(true) returns an empty string — i.e. neither the --name flag nor a KOPS_CLUSTER_NAME was supplied and no cluster state exists — the command aborts with this error. kops needs the cluster name to locate and modify the instance group.
Source
Thrown at cmd/kops/delete_instancegroup.go:72
Yes bool
ClusterName string
GroupName string
}
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()
View on GitHub (pinned to 4c8573c808)
Solutions
- Pass the cluster explicitly: `kops delete instancegroup --name <cluster-name> workers`.
- Export KOPS_CLUSTER_NAME=<cluster-name> in the shell or CI environment.
- Check scripts/aliases that previously set --name and restore it.
Example fix
// before $ kops delete instancegroup workers error: --name is required // after $ kops delete instancegroup --name prod.example.com workers
Defensive patterns
Strategy: validation
Validate before calling
[ -n "${KOPS_CLUSTER_NAME:-$CLUSTER_NAME}" ] || { echo "set --name or KOPS_CLUSTER_NAME" >&2; exit 1; } Prevention
- Always pass --name in scripts and CI instead of relying on ambient state.
- Export KOPS_CLUSTER_NAME in shell profiles/CI environments.
- Set kops state store config consistently across automation.
When it happens
Trigger: Running `kops delete instancegroup workers` without --name, without KOPS_CLUSTER_NAME set, and outside a kops state-store context that can infer the cluster.
Common situations: Scripting/CI where the --name flag was dropped; relying on KOPS_CLUSTER_NAME that isn't exported in the shell; deleting an instance group from a directory other than where the cluster name was set via dotenv/flags.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — 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/87bf5eb1f774fb63.
Report an issue: GitHub.