kubernetes/kops · error
error getting clientset: %v
Error message
error getting clientset: %v
What it means
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.
Source
Thrown at cmd/kops/create_keypair.go:158
cmd.Flags().BoolVar(&options.Primary, "primary", options.Primary, "Make the keypair the one used to issue certificates")
return cmd
}
// RunCreateKeypair adds a custom CA certificate and private key.
func RunCreateKeypair(ctx context.Context, f *util.Factory, out io.Writer, options *CreateKeypairOptions) error {
if !rotatableKeysetFilter(options.Keyset, nil) {
return fmt.Errorf("adding keypair to %q is not supported", options.Keyset)
}
cluster, err := GetCluster(ctx, f, options.ClusterName)
if err != nil {
return fmt.Errorf("error getting cluster: %q: %v", options.ClusterName, err)
}
clientSet, err := f.KopsClient()
if err != nil {
return fmt.Errorf("error getting clientset: %v", err)
}
keyStore, err := clientSet.KeyStore(cluster)
if err != nil {
return fmt.Errorf("error getting keystore: %v", err)
}
if options.Keyset != "all" {
return createKeypair(ctx, out, options, options.Keyset, keyStore)
}
keysets, err := keyStore.ListKeysets()
if err != nil {
return fmt.Errorf("listing keysets: %v", err)
}
for name := range keysets {
if rotatableKeysetFilter(name, nil) {View on GitHub (pinned to 4c8573c808)
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.
Example fix
// before kops create keypair cluster.k8s.local --keyset ca # different kops version than cluster // after kops version # match binary version to cluster's kops version, then retry kops create keypair cluster.k8s.local --keyset ca
Defensive patterns
Strategy: try-catch
Validate before calling
kops get clusters >/dev/null 2>&1 || { echo "kops client cannot initialize against state store"; exit 1; } Try / catch
if ! out=$(kops create keypair "$CLUSTER" --keyset ca 2>&1); then
case "$out" in
*"error getting clientset"*) echo "Client init failed; check kops version and config: $out";;
esac
fi Prevention
- 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.
When it happens
Trigger: 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).
Common situations: Corrupt or incompatible kops config in the state store; version mismatch between kOps CLI and state-store layout; environment misconfiguration affecting client construction.
Related errors
- error creating kops config template: %w
- error creating gcp machine template: %w
- error building machine deployments: %w
- server-side addons client does not support Addons::Replace
- clientset bound to cluster %q, got cluster %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/9eb8828d8499754f.
Report an issue: GitHub.