{"record":{"id":"3c66a160dfd41439","repo":"kubernetes/kops","slug":"cannot-specify-additional-objects-when-multiple-cl","errorCode":null,"errorMessage":"cannot specify additional objects when multiple clusters are created","messagePattern":"cannot specify additional objects when multiple clusters are created","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create.go","lineNumber":219,"sourceCode":"\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(&sb, \"Added ssh credential\\n\")\n\n\t\t\tcase *unstructured.Unstructured:\n\t\t\t\taddons = append(addons, kubemanifest.NewObject(v.Object))\n\n\t\t\tdefault:\n\t\t\t\tklog.V(2).Infof(\"Type of object was %T\", v)\n\t\t\t\treturn fmt.Errorf(\"unhandled kind %q in %s\", gvk, f)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Because not all addons support labels, we can only support one cluster here.\n\t// A single cluster per create is probably a good idea anyway.\n\tif len(addons) != 0 {\n\t\tif len(clusters) > 1 {\n\t\t\treturn fmt.Errorf(\"cannot specify additional objects when multiple clusters are created\")\n\t\t}\n\t\tif len(clusters) == 0 {\n\t\t\treturn fmt.Errorf(\"must specify a cluster when creating additional objects\")\n\t\t}\n\t\tcluster := clusters[0]\n\n\t\taddonsClient := clientset.AddonsFor(cluster)\n\n\t\tif err := addonsClient.Replace(addons); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing additional objects: %v\", err)\n\t\t}\n\t}\n\n\t{\n\t\t// If there is a value in this sb, this should mean that we have something to deploy\n\t\t// so let's advise the user how to engage the cloud provider and deploy\n\t\tif sb.String() != \"\" {\n\t\t\tfmt.Fprintf(&sb, \"\\n\")","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create.go#L201-L237","documentation":"Add-on (unstructured) objects have no cluster labels, so RunCreate attaches them only when exactly one cluster is created in the same invocation, using clusters[0]. If the -f input creates more than one Cluster plus additional objects, the target is ambiguous and the command aborts.","triggerScenarios":"`kops create -f bundle.yaml` where bundle.yaml contains two Cluster documents plus unstructured add-on manifests; or a directory-style -f concat producing multiple clusters and addons together.","commonSituations":"Multi-cluster provisioning bundles; generated config files that combine several clusters and shared add-ons; users migrating from per-file apply scripts to one big -f file.","solutions":["Split the input: run `kops create -f` once per cluster, with add-ons only in the single-cluster file","Remove the extra unstructured add-on objects from the multi-cluster file and apply them separately with `kops replace -f`","Add cluster-scoping labels / use separate files per cluster"],"exampleFix":"// before\nkops create -f bundle.yaml   # 2 clusters + addons\n// after\nkops create -f cluster1+addons.yaml\nkops create -f cluster2.yaml","handlingStrategy":"validation","validationCode":"clusters, addons := classify(docs)\nif len(clusters) > 1 && len(addons) > 0 {\n    return fmt.Errorf(\"split input: addons only allowed with exactly one cluster\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One cluster per -f file when bundling add-ons","Split multi-cluster bundles into per-cluster files","Review generated bundles for multiple Cluster documents"],"tags":["kops","cli","addons","ambiguity"],"backgroundTag":"ambiguous-target-resource","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"}