{"record":{"id":"af5363f663a42ba9","repo":"kubernetes/kops","slug":"cluster-q-not-found","errorCode":null,"errorMessage":"cluster %q not found","messagePattern":"cluster %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create.go","lineNumber":167,"sourceCode":"\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)\n\n\t\t\tcase *kopsapi.SSHCredential:\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 SSHCredential\", kopsapi.LabelClusterName)\n\t\t\t\t}\n\t\t\t\tif v.Spec.PublicKey == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"spec.PublicKey is required\")","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create.go#L149-L185","documentation":"RunCreate successfully queried the backend for the labeled cluster but received a nil result, meaning no cluster with that name exists in the state store. kOps surfaces this as a distinct 'not found' message rather than a backend error.","triggerScenarios":"`kops create -f ig.yaml` where the InstanceGroup's `kops.k8s.io/cluster` label names a cluster that was never created or has been deleted, in the same command run or a prior one.","commonSituations":"Typo in the cluster label; creating instance groups before `kops create -f cluster.yaml` (both in one -f file where the IG section precedes the Cluster section, or in separate runs); cluster deleted by `kops delete cluster`.","solutions":["Create the cluster first (`kops create -f cluster.yaml`) then create the instance group","Fix the `kops.k8s.io/cluster` label to match an existing cluster name exactly","Check with `kops get clusters` which clusters exist in KOPS_STATE_STORE"],"exampleFix":"// before\nlabels:\n  kops.k8s.io/cluster: myclster.example.com\n// after\nlabels:\n  kops.k8s.io/cluster: mycluster.example.com","handlingStrategy":"validation","validationCode":"clusterName := ig.Labels[kopsapi.LabelClusterName]\nif _, err := clientset.GetCluster(ctx, clusterName); err != nil || clusterName == \"\" {\n    return fmt.Errorf(\"cluster %q does not exist; create it first\", clusterName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check the label value against `kops get clusters` output","Order create operations: cluster before instance groups","Avoid hand-typing cluster names; source them from the cluster spec"],"tags":["kops","cli","instancegroup","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}