{"record":{"id":"f4da32a2a79417ff","repo":"kubernetes/kops","slug":"must-specify-q-label-with-cluster-name-to-create","errorCode":null,"errorMessage":"must specify %q label with cluster name to create instanceGroup","messagePattern":"must specify %q label with cluster name to create instanceGroup","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create.go","lineNumber":159,"sourceCode":"\t\t\t\terr = cloudup.PerformAssignments(v, vfsContext, cloud)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error populating configuration: %v\", err)\n\t\t\t\t}\n\t\t\t\t_, err = clientset.CreateCluster(ctx, v)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif apierrors.IsAlreadyExists(err) {\n\t\t\t\t\t\treturn fmt.Errorf(\"cluster %q already exists\", v.ObjectMeta.Name)\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"error creating cluster: %v\", err)\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(&sb, \"Created cluster/%s\\n\", v.ObjectMeta.Name)\n\t\t\t\tclusters = append(clusters, v)\n\t\t\t\t// cSpec = true\n\n\t\t\tcase *kopsapi.InstanceGroup:\n\t\t\t\tclusterName = v.ObjectMeta.Labels[kopsapi.LabelClusterName]\n\t\t\t\tif clusterName == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"must specify %q label with cluster name to create instanceGroup\", kopsapi.LabelClusterName)\n\t\t\t\t}\n\t\t\t\tcluster, err := clientset.GetCluster(ctx, clusterName)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error querying cluster %q: %v\", clusterName, err)\n\t\t\t\t}\n\n\t\t\t\tif cluster == nil {\n\t\t\t\t\treturn fmt.Errorf(\"cluster %q not found\", clusterName)\n\t\t\t\t}\n\n\t\t\t\t_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, v, metav1.CreateOptions{})\n\t\t\t\tif err != nil {\n\t\t\t\t\tif apierrors.IsAlreadyExists(err) {\n\t\t\t\t\t\treturn fmt.Errorf(\"instanceGroup %q already exists\", v.ObjectMeta.Name)\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"error creating instanceGroup: %v\", err)\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(&sb, \"Created instancegroup/%s\\n\", v.ObjectMeta.Name)","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create.go#L141-L177","documentation":"`kops create -f` decodes each YAML section and dispatches by Go type. When it encounters a kops InstanceGroup object, it requires the metadata.labels entry keyed by kopsapi.LabelClusterName (\"kops.k8s.io/cluster\") to know which cluster the instance group belongs to; without it the command cannot resolve the parent cluster and fails fast.","triggerScenarios":"Running `kops create -f ig.yaml` where ig.yaml contains a kind: InstanceGroup document whose metadata is missing the label `kops.k8s.io/cluster: <clustername>` (or misspells the label key).","commonSituations":"Hand-written instance group manifests copied from old blog posts predating the label requirement; templates where labels were stripped; generating IGs with tooling that omits ObjectMeta labels.","solutions":["Add `kops.k8s.io/cluster: <cluster-name>` under metadata.labels of the InstanceGroup document","Create the instance group via `kops create ig --name <cluster> ...` or `kops create -f` after fixing the manifest","Verify the label key is exactly kops.k8s.io/cluster (not clusterName or kops/cluster)"],"exampleFix":"# before\nmetadata:\n  name: nodes\nspec: {}\n# after\nmetadata:\n  name: nodes\n  labels:\n    kops.k8s.io/cluster: mycluster.example.com\nspec: {}","handlingStrategy":"validation","validationCode":"ig, _ := decodeSection(yaml)\nif v, ok := ig.(*kopsapi.InstanceGroup); ok && v.ObjectMeta.Labels[kopsapi.LabelClusterName] == \"\" {\n    return fmt.Errorf(\"IG %s missing label %s\", v.Name, kopsapi.LabelClusterName)\n}","typeGuard":"func needsClusterLabel(o runtime.Object) (*kopsapi.InstanceGroup, bool) {\n    ig, ok := o.(*kopsapi.InstanceGroup)\n    return ig, ok && ig.ObjectMeta.Labels[kopsapi.LabelClusterName] != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always template metadata.labels with the cluster name when generating IG manifests","Use `kops create ig` which sets the label for you","Lint manifests for the kops.k8s.io/cluster label before running create"],"tags":["kops","cli","instancegroup","missing-label"],"backgroundTag":"missing-required-label","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"}