kubernetes/kops · error
cluster %q not found
Error message
cluster %q not found
What it means
GetCluster fetches the cluster spec from the cluster registry via clientset.GetCluster. The registry store returns (nil, nil) when no cluster object exists under b.ClusterName, and this code converts that nil result into an explicit 'cluster %q not found' error. It guards callers (GetFullCluster, GetCloud, GetInstanceGroups, GetAssetBuilder) from proceeding with a nil cluster.
Source
Thrown at pkg/commands/toolbox_enroll.go:664
func (b *ConfigBuilder) GetCluster(ctx context.Context) (*kops.Cluster, error) {
if b.Cluster != nil {
return b.Cluster, nil
}
if b.ClusterName == "" {
return nil, fmt.Errorf("ClusterName is missing")
}
clientset, err := b.GetClientset(ctx)
if err != nil {
return nil, err
}
cluster, err := clientset.GetCluster(ctx, b.ClusterName)
if err != nil {
return nil, err
}
if cluster == nil {
return nil, fmt.Errorf("cluster %q not found", b.ClusterName)
}
b.Cluster = cluster
return cluster, nil
}
func (b *ConfigBuilder) GetAssetBuilder(ctx context.Context) (*assets.AssetBuilder, error) {
if b.AssetBuilder != nil {
return b.AssetBuilder, nil
}
clientset, err := b.GetClientset(ctx)
if err != nil {
return nil, err
}
cluster, err := b.GetCluster(ctx)
if err != nil {
return nil, errView on GitHub (pinned to 4c8573c808)
Solutions
- Verify the exact cluster name with `kops get clusters` against the configured state store (`kops get --state <store>`).
- Check KOPS_STATE_STORE / --state points at the bucket where the cluster was actually created.
- Correct the --name flag (or cluster name in config) to match an existing cluster.
- If the cluster is genuinely missing, create it with `kops create cluster` before enrolling.
Example fix
// before kops toolbox enroll --name prod.example.com // after kops toolbox enroll --name prod.example.com --state s3://correct-bucket # name verified via kops get
Defensive patterns
Strategy: validation
Validate before calling
// Verify the cluster exists before running toolbox enroll
out, err := exec.Command("kops", "get", "cluster", clusterName, "--state", stateStore).Output()
if err != nil {
return fmt.Errorf("cluster %q does not exist in state store %s", clusterName, stateStore)
} Try / catch
if err != nil {
if strings.Contains(err.Error(), "not found") {
// prompt user to verify --name and KOPS_STATE_STORE
}
return err
} Prevention
- Always pass --state explicitly rather than relying on KOPS_STATE_STORE env
- Copy the cluster name from `kops get` output instead of typing it
- Check that the state store bucket/credentials belong to the intended environment
When it happens
Trigger: Calling any ConfigBuilder method that resolves the cluster when b.ClusterName does not exist in the state store — e.g. kops toolbox enroll against a cluster name that was never created or was deleted.
Common situations: Typo in --name / KOPS_CLUSTER_NAME; pointing KOPS_STATE_STORE at the wrong bucket/path; cluster deleted by another operator; state store backend misconfigured (wrong region/credentials silently listing an empty store); stale kubeconfig-style cluster name from another environment.
Related errors
- error loading NodeupConfig %q: %v
- error querying cluster %q: %v
- cluster %q not found
- error getting cluster: %q: %v
- listing keysets: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/3d21b73c18f5a6f0.
Report an issue: GitHub.