{"record":{"id":"ad7ca4c23825865f","repo":"kubernetes/kops","slug":"cluster-not-found-q-ad7ca4","errorCode":null,"errorMessage":"cluster not found %q","messagePattern":"cluster not found %q","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_instances.go","lineNumber":105,"sourceCode":"\n\topt.CreateKubecfgOptions.AddCommonFlags(cmd.Flags())\n\n\treturn cmd\n}\n\nfunc RunGetInstances(ctx context.Context, f *util.Factory, out io.Writer, options *GetInstancesOptions) error {\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcluster, err := clientset.GetCluster(ctx, options.ClusterName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif cluster == nil {\n\t\treturn fmt.Errorf(\"cluster not found %q\", options.ClusterName)\n\t}\n\n\tcloud, err := cloudup.BuildCloud(cluster)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trestConfig, err := f.RESTConfig(ctx, cluster, options.CreateKubecfgOptions)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thttpClient, err := f.HTTPClient(restConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tk8sClient, err := kubernetes.NewForConfigAndClient(restConfig, httpClient)","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_instances.go#L87-L123","documentation":"RunGetInstances in `kops get instances` looks up the target cluster via clientset.GetCluster. In this kops state-store backend, a miss returns (nil, nil), so the command explicitly checks for a nil cluster and throws \"cluster not found %q\". It means the given cluster name does not correspond to any cluster registered in the configured state store.","triggerScenarios":"Running `kops get instances <NAME>` (or with --name) where options.ClusterName does not match a cluster in the kops state store; GetCluster returns nil with no error and line 105 raises this error.","commonSituations":"Typo in the cluster name; wrong KOPS_STATE_STORE (e.g. pointing at an empty/different S3 bucket or different region prefix); cluster was deleted; running without a default cluster set in ~/.kube/config or via KOPS_CLUSTER_NAME; name missing the full DNS suffix (e.g. 'foo' instead of 'foo.example.com').","solutions":["Run `kops get clusters` (with the same --state flag) to list valid cluster names and copy the exact name","Verify KOPS_STATE_STORE points to the state store that actually holds the cluster (e.g. s3://your-bucket)","Set KOPS_CLUSTER_NAME or pass the fully-qualified cluster name to avoid ambiguity","If the cluster was deleted intentionally, recreate it with `kops create cluster` before listing instances"],"exampleFix":"// before\nkops get instances mycluster\n// after\nkops get clusters            # confirm exact name\nkops get instances mycluster.example.com --state s3://correct-bucket","handlingStrategy":"validation","validationCode":"name=\"$1\"\nkops get clusters --state \"${KOPS_STATE_STORE:-s3://my-bucket}\" | grep -Fx \"$name\" || { echo \"cluster $name not in state store\"; exit 1; }","typeGuard":"cluster, err := clientset.GetCluster(ctx, name)\nif err != nil { return err }\nif cluster == nil { return fmt.Errorf(\"cluster %q not found in state store %s\", name, stateStore) }","tryCatchPattern":"out, err := runGetInstances(name)\nif err != nil {\n    if strings.Contains(err.Error(), \"cluster not found\") {\n        fmt.Fprintf(os.Stderr, \"hint: run `kops get clusters` and check KOPS_STATE_STORE\\n\")\n    }\n    return err\n}","preventionTips":["Always set KOPS_CLUSTER_NAME or pass the fully-qualified cluster DNS name","Pin KOPS_STATE_STORE in your shell profile per environment","Run `kops get clusters` first when switching environments or state stores","Use shell completion (ValidArgsFunction) instead of typing cluster names"],"tags":["cli","cluster-lookup","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"}