{"record":{"id":"9eb8828d8499754f","repo":"kubernetes/kops","slug":"error-getting-clientset-v","errorCode":null,"errorMessage":"error getting clientset: %v","messagePattern":"error getting clientset: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_keypair.go","lineNumber":158,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"listing keysets: %v\", err)\n\t}\n\n\tfor name := range keysets {\n\t\tif rotatableKeysetFilter(name, nil) {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_keypair.go#L140-L176","documentation":"After loading the cluster, RunCreateKeypair builds a kops clientset via f.KopsClient(). Failure constructing the API client (registry/REST client wiring against the configured state store) is wrapped with this message.","triggerScenarios":"f.KopsClient() returns an error during `kops create keypair` — typically bad kOps configuration, unresolvable state store, or an internal client initialization failure (cmd/kops/create_keypair.go:158).","commonSituations":"Corrupt or incompatible kops config in the state store; version mismatch between kOps CLI and state-store layout; environment misconfiguration affecting client construction.","solutions":["Retry with the same kOps version that manages the cluster (avoid version skew).","Verify state store config (`kops get clusters` works) to isolate client construction from auth.","Set --v=8 (or KOPS debug flags) for verbose error detail.","Reinstall/refresh kops if the binary or its vendored config is inconsistent."],"exampleFix":"// before\nkops create keypair cluster.k8s.local --keyset ca   # different kops version than cluster\n// after\nkops version  # match binary version to cluster's kops version, then retry\nkops create keypair cluster.k8s.local --keyset ca","handlingStrategy":"try-catch","validationCode":"kops get clusters >/dev/null 2>&1 || { echo \"kops client cannot initialize against state store\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! out=$(kops create keypair \"$CLUSTER\" --keyset ca 2>&1); then\n  case \"$out\" in\n    *\"error getting clientset\"*) echo \"Client init failed; check kops version and config: $out\";;\n  esac\nfi","preventionTips":["Keep the kOps CLI version matched to the cluster's kOps version.","Ensure a healthy base config: `kops get clusters` succeeds before mutations.","Avoid mixing kOps installations (homebrew vs binary) with different defaults."],"tags":["clientset","api-client","kops"],"backgroundTag":"client-initialization-failed","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"}