{"record":{"id":"234e5085e409c1a9","repo":"kubernetes/kops","slug":"error-reading-cluster-configuration-v","errorCode":null,"errorMessage":"error reading cluster configuration: %v","messagePattern":"error reading cluster configuration: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/root.go","lineNumber":350,"sourceCode":"\t\t}\n\t}\n\n\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","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/root.go#L332-L368","documentation":"This error is returned by kops' GetCluster helper when the clientset call to read the cluster's configuration from the state store fails. It wraps the underlying error (state store connection issues, permissions, network problems, or cluster simply not existing in the state store). It is thrown because kops requires the full cluster spec before performing subcommands like creating instance groups or secrets.","triggerScenarios":"Any caller (RunCreateInstanceGroup, RunCreateKeypair, RunCreateSecret*, RunCreateSSHPublicKey) invokes clientset.GetCluster and the underlying registry returns a non-nil error — e.g. the state store is unreachable, the cluster object does not exist (ErrNotFound), or VFS credentials are invalid.","commonSituations":"Typo in --name or KOPS_CLUSTER_NAME; KOPS_STATE_STORE env var unset, wrong, or the bucket not existing; cluster never created so no config exists in the state store; expired/missing cloud credentials preventing VFS/S3 access.","solutions":["Verify the cluster exists: kops get clusters (check the exact name and that KOPS_STATE_STORE points at the right store).","Export the correct state store: export KOPS_STATE_STORE=s3://<bucket> (or set --state flag).","Run with -v=10 to see the wrapped underlying error and fix that (auth, networking, permissions).","If the cluster is gone, recreate it with kops create cluster before running the subcommand."],"exampleFix":"// before\nkops create ig nodes --name wrong-cluster-name\n// after\nexport KOPS_STATE_STORE=s3://my-state-bucket\nkops get clusters  # confirm exact name\nkops create ig nodes --name cluster.k8s.local","handlingStrategy":"validation","validationCode":"export KOPS_STATE_STORE=s3://my-state-bucket\nkops get clusters | grep -Fx \"$CLUSTER_NAME\" || { echo \"cluster $CLUSTER_NAME not in state store\"; exit 1; }","typeGuard":null,"tryCatchPattern":"cluster, err := GetCluster(ctx, clusterName)\nif err != nil {\n    return fmt.Errorf(\"could not load cluster %q from state store %q: %w\", clusterName, os.Getenv(\"KOPS_STATE_STORE\"), err)\n}","preventionTips":["Always export KOPS_STATE_STORE in shell profile or CI env before kops commands","Use fully-qualified cluster DNS names in scripts","Run kops get clusters first to validate names in automation","Use --v=10 when debugging state store connectivity"],"tags":["kops","state-store","cluster-config"],"backgroundTag":"cluster-config-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"}