{"record":{"id":"609a4fec85c65599","repo":"kubernetes/kops","slug":"cluster-q-not-found-609a4f","errorCode":null,"errorMessage":"cluster %q not found","messagePattern":"cluster %q not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/root.go","lineNumber":353,"sourceCode":"\treturn c.clusterName\n}\n\nfunc GetCluster(ctx context.Context, factory commandutils.Factory, clusterName string) (*kopsapi.Cluster, error) {\n\tif clusterName == \"\" {\n\t\treturn nil, field.Required(field.NewPath(\"clusterName\"), \"Cluster name is required\")\n\t}\n\n\tclientset, err := factory.KopsClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcluster, err := clientset.GetCluster(ctx, clusterName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading cluster configuration: %v\", err)\n\t}\n\tif cluster == nil {\n\t\treturn nil, fmt.Errorf(\"cluster %q not found\", clusterName)\n\t}\n\n\tif clusterName != cluster.ObjectMeta.Name {\n\t\treturn nil, fmt.Errorf(\"cluster name did not match expected name: %v vs %v\", clusterName, cluster.ObjectMeta.Name)\n\t}\n\treturn cluster, nil\n}\n\nfunc GetClusterNameForCompletionNoKubeconfig(clusterArgs []string) (clusterName string, completions []string, directive cobra.ShellCompDirective) {\n\tif len(clusterArgs) > 0 {\n\t\treturn clusterArgs[0], nil, 0\n\t}\n\n\tif rootCommand.clusterName != \"\" {\n\t\treturn rootCommand.clusterName, nil, 0\n\t}\n\n\treturn \"\", []string{\"--name\"}, cobra.ShellCompDirectiveNoFileComp","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/root.go#L335-L371","documentation":"GetCluster in kops can return a nil cluster with a nil error (the clientset convention for 'not found'). This error is raised to convert that silent nil result into an explicit 'cluster not found' message. It means the state store has no cluster object with the given name.","triggerScenarios":"clientset.GetCluster returns (nil, nil) — i.e. no cluster configuration exists at the requested name in the state store — while running commands like create instancegroup, create keypair, create secret, or create sshpublickey.","commonSituations":"Typo in the cluster name or case mismatch; KOPS_STATE_STORE pointing to a different bucket than the one the cluster lives in; DNS/name mismatch such as using a short name instead of the fully-qualified cluster name (e.g. 'mycluster' vs 'mycluster.k8s.local').","solutions":["List clusters with kops get clusters and copy the exact cluster name.","Use the fully-qualified cluster DNS name (e.g. name.k8s.local for gossip clusters).","Confirm KOPS_STATE_STORE / --state points at the store containing the cluster.","Create the cluster first (kops create cluster ...) if it does not exist yet."],"exampleFix":"// before\nkops create ig nodes --name mycluster\n// after\nkops get clusters  # shows: mycluster.k8s.local\nkops create ig nodes --name mycluster.k8s.local","handlingStrategy":"validation","validationCode":"EXISTING=$(kops get clusters -o name | grep -F \"$CLUSTER_NAME\") || { echo \"cluster $CLUSTER_NAME does not exist\"; exit 1; }","typeGuard":null,"tryCatchPattern":"cluster, err := GetCluster(ctx, clusterName)\nif err != nil {\n    return err\n}\nif cluster == nil {\n    return fmt.Errorf(\"cluster %q not found in state store; run 'kops get clusters' to list valid names\", clusterName)\n}","preventionTips":["Copy cluster names verbatim from kops get clusters output","Remember gossip clusters require the .k8s.local suffix","Pin KOPS_STATE_STORE per environment (dev/staging/prod)","Validate names in CI before running mutating commands"],"tags":["kops","cluster-not-found","state-store"],"backgroundTag":"cluster-not-found","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"}