kubernetes/kops · error
must specify ID of instance or name of node to delete
Error message
must specify ID of instance or name of node to delete
What it means
The delete instance command's argument validator requires the cloud instance ID or Kubernetes node name as a positional argument; this fires when no positional args were given, so there is nothing to identify the instance to delete.
Source
Thrown at cmd/kops/delete_instance.go:128
deleteInstanceShort := i18n.T(`Delete an instance.`)
var options DeleteInstanceOptions
options.initDefaults()
cmd := &cobra.Command{
Use: "instance INSTANCE|NODE",
Short: deleteInstanceShort,
Long: deleteInstanceLong,
Example: deleteInstanceExample,
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 ID of instance or name of node to delete")
}
options.InstanceID = args[0]
if len(args) != 1 {
return fmt.Errorf("can only delete one instance at a time")
}
return nil
},
ValidArgsFunction: completeInstanceOrNode(f, &options),
RunE: func(cmd *cobra.Command, args []string) error {
return RunDeleteInstance(cmd.Context(), f, out, &options)
},
}
cmd.Flags().BoolVar(&options.CloudOnly, "cloudonly", options.CloudOnly, "Perform deletion update without confirming progress with Kubernetes")
cmd.Flags().BoolVar(&options.Surge, "surge", options.Surge, "Surge by detaching the node from the ASG before deletion")
View on GitHub (pinned to 4c8573c808)
Solutions
- Provide the instance ID or node name: `kops delete instance i-0abc123`.
- If scripting, verify the variable holding the ID is non-empty before invoking kops.
- List instances first (`kops get instances` / kubectl get nodes) to find the correct identifier.
Example fix
// before kops delete instance --name cluster.example.com // after kops delete instance i-0abc123 --name cluster.example.com
Defensive patterns
Strategy: validation
Validate before calling
instanceID := os.Getenv("INSTANCE_ID")
if instanceID == "" {
return fmt.Errorf("instance ID must be resolved before calling kops delete instance")
}
args = append(args, instanceID) Prevention
- Check that the positional argument variable is non-empty before invoking.
- Fetch the instance ID via `kops get instances` first.
- Use shell `set -u` to catch unset variables in scripts.
When it happens
Trigger: Running `kops delete instance` with flags only and no instance ID/node name argument.
Common situations: Users expecting an interactive picker or --all style flag; scripts where the instance ID variable was empty.
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
- must specify the name of the instance group to delete
- cluster is required
- instance-group is required
- host is required
- name is required
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/734b7de1b81c7f49.
Report an issue: GitHub.