{"record":{"id":"b57a845a41d80702","repo":"kubernetes/kops","slug":"error-getting-cluster-q-v-b57a84","errorCode":null,"errorMessage":"error getting cluster: %q: %v","messagePattern":"error getting cluster: %q: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_keypair.go","lineNumber":153,"sourceCode":"\t\t},\n\t}\n\n\tcmd.Flags().StringVar(&options.CertPath, \"cert\", options.CertPath, \"Path to CA certificate\")\n\tcmd.Flags().StringVar(&options.PrivateKeyPath, \"key\", options.PrivateKeyPath, \"Path to CA private key\")\n\tcmd.Flags().BoolVar(&options.Primary, \"primary\", options.Primary, \"Make the keypair the one used to issue certificates\")\n\n\treturn cmd\n}\n\n// RunCreateKeypair adds a custom CA certificate and private key.\nfunc RunCreateKeypair(ctx context.Context, f *util.Factory, out io.Writer, options *CreateKeypairOptions) error {\n\tif !rotatableKeysetFilter(options.Keyset, nil) {\n\t\treturn fmt.Errorf(\"adding keypair to %q is not supported\", options.Keyset)\n\t}\n\n\tcluster, err := GetCluster(ctx, f, options.ClusterName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting cluster: %q: %v\", options.ClusterName, err)\n\t}\n\n\tclientSet, err := f.KopsClient()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting clientset: %v\", err)\n\t}\n\n\tkeyStore, err := clientSet.KeyStore(cluster)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting keystore: %v\", err)\n\t}\n\n\tif options.Keyset != \"all\" {\n\t\treturn createKeypair(ctx, out, options, options.Keyset, keyStore)\n\t}\n\n\tkeysets, err := keyStore.ListKeysets()\n\tif err != nil {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_keypair.go#L135-L171","documentation":"RunCreateKeypair resolves the cluster via GetCluster (which reads cluster config from the kOps state store) before touching the keystore. Any failure loading the cluster object is wrapped with this message, embedding the cluster name and underlying error.","triggerScenarios":"`kops create keypair <cluster> ...` where GetCluster fails: cluster not found in state store, wrong --state / KOPS_STATE_STORE, malformed registry path, or connectivity/permission failure to the state backend (cmd/kops/create_keypair.go:153).","commonSituations":"Wrong KOPS_STATE_STORE env var (e.g. pointing at an empty bucket); cluster name typo; expired cloud credentials blocking S3/GCS access; cluster was deleted.","solutions":["Verify the cluster exists: `kops get clusters` with the same --state.","Check KOPS_STATE_STORE / --state points at the correct store and credentials allow access.","Confirm the exact cluster name (fully qualified, e.g. cluster.k8s.local).","Test state-store access directly (aws s3 ls / gsutil ls on the bucket)."],"exampleFix":"// before\nKOPS_STATE_STORE=mystore kops create keypair cluster.k8s.local --keyset ca\n// after\nexport KOPS_STATE_STORE=s3://my-correct-bucket\nkops create keypair cluster.k8s.local --keyset ca","handlingStrategy":"try-catch","validationCode":"kops get cluster \"$CLUSTER\" >/dev/null 2>&1 || { echo \"cannot resolve cluster $CLUSTER in state store\"; exit 1; }\nkops create keypair \"$CLUSTER\" --keyset ca","typeGuard":null,"tryCatchPattern":"if ! out=$(kops create keypair \"$CLUSTER\" --keyset ca 2>&1); then\n  case \"$out\" in\n    *\"error getting cluster\"*) echo \"Fix state store / cluster name: $out\";;\n    *) echo \"Unexpected failure: $out\";;\n  esac\n  exit 1\nfi","preventionTips":["Pin KOPS_STATE_STORE in CI environments and scripts.","Always use the fully qualified cluster name from `kops get clusters`.","Pre-check cloud credentials (aws sts get-caller-identity) before kOps operations."],"tags":["cluster-lookup","state-store","kops"],"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"}