{"record":{"id":"0bad6aa285cb73c9","repo":"kubernetes/kops","slug":"instance-group-is-required","errorCode":null,"errorMessage":"instance-group is required","messagePattern":"instance-group is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/toolbox_enroll.go","lineNumber":96,"sourceCode":"\tPodCIDRs []string\n\n\tkubeconfig.CreateKubecfgOptions\n}\n\nfunc (o *ToolboxEnrollOptions) InitDefaults() {\n\to.SSHUser = \"root\"\n\to.SSHPort = 22\n}\n\nfunc RunToolboxEnroll(ctx context.Context, f commandutils.Factory, out io.Writer, options *ToolboxEnrollOptions) error {\n\tif !featureflag.Metal.Enabled() {\n\t\treturn fmt.Errorf(\"bare-metal support requires the Metal feature flag to be enabled\")\n\t}\n\tif options.ClusterName == \"\" {\n\t\treturn fmt.Errorf(\"cluster is required\")\n\t}\n\tif options.InstanceGroup == \"\" {\n\t\treturn fmt.Errorf(\"instance-group is required\")\n\t}\n\tif options.Host == \"\" {\n\t\t// Technically we could build the host resource without the PKI, but this isn't the case we are targeting right now.\n\t\treturn fmt.Errorf(\"host is required\")\n\t}\n\n\t// Resolve KOPS_BASE_URL early so that kops.Version is overridden\n\t// before the version downgrade check in ApplyClusterCmd.Run.\n\tif _, err := wellknownassets.BaseURL(); err != nil {\n\t\treturn err\n\t}\n\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconfigBuilder := &ConfigBuilder{","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/toolbox_enroll.go#L78-L114","documentation":"Enrolling a host requires knowing which InstanceGroup it will join (for roles, spec inheritance, etc.). When `options.InstanceGroup` is empty, RunToolboxEnroll returns this validation error before doing any SSH work.","triggerScenarios":"Running `kops toolbox enroll` with --cluster and --host but without `--instance-group`.","commonSituations":"Typos in the flag name (e.g. `--instancegroup`); scripts parameterized for other kops commands that use different flag spellings; forgetting that enroll does not infer the IG from the host.","solutions":["Add `--instance-group <ig-name>` matching an existing InstanceGroup in the cluster","List candidate groups with `kops get instancegroups --name <cluster>` and pick the right one","Fix variable interpolation in scripts so the IG name isn't empty"],"exampleFix":"// before\nkops toolbox enroll --cluster c.example.com --host 10.0.0.5\n// after\nkops toolbox enroll --cluster c.example.com --instance-group metal --host 10.0.0.5","handlingStrategy":"validation","validationCode":"IG=\"${IG:?instance-group is required}\"\nkops get instancegroup --name \"$CLUSTER\" \"$IG\" >/dev/null || { echo \"instance group $IG not found\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass --instance-group on every enroll invocation","Verify the IG exists in the cluster before enrolling","Use consistent flag spellings across your automation"],"tags":["cli","validation","missing-argument","instance-groups"],"backgroundTag":"missing-required-flag","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}