kubernetes/kops · error
no clusters found
Error message
no clusters found
What it means
After listing all clusters from the state store, RunGetClusters filters them by the requested names and fails with 'no clusters found' when the resulting list is empty. This happens when no clusters exist in the state store at all, or when name filtering returned nothing without an explicit 'not found' error path. It is thrown instead of printing empty output so users get a clear signal.
Source
Thrown at cmd/kops/get_cluster.go:156
clusterList = append(clusterList, cluster)
}
} else {
list, err := client.ListClusters(ctx, metav1.ListOptions{})
if err != nil {
return err
}
for i := range list.Items {
clusterList = append(clusterList, &list.Items[i])
}
}
clusters, err := filterClustersByName(options.ClusterNames, clusterList)
if err != nil {
return err
}
if len(clusters) == 0 {
return fmt.Errorf("no clusters found")
}
if options.FullSpec {
var err error
clusters, err = fullClusterSpecs(ctx, client.VFSContext(), clusters)
if err != nil {
return err
}
fmt.Fprint(out, get_cluster_full_warning)
}
var obj []runtime.Object
if options.Output != OutputTable {
for _, c := range clusters {
obj = append(obj, c)
}
}View on GitHub (pinned to 4c8573c808)
Solutions
- Verify the state store: `kops get clusters --state s3://<correct-bucket>` and confirm KOPS_STATE_STORE is correct.
- List the bucket contents (`aws s3 ls s3://bucket/`) to confirm cluster manifests exist under the expected path.
- Create a cluster first with `kops create cluster` if none exists.
- Check for state-store path prefixes — kops stores under a prefix if one was used at create time.
Example fix
// before KOPS_STATE_STORE=s3://wrong-bucket kops get clusters // after KOPS_STATE_STORE=s3://my-kops-bucket kops get clusters
Defensive patterns
Strategy: validation
Validate before calling
# precondition: state store has clusters
aws s3 ls "${KOPS_STATE_STORE#s3://}/cluster-completed.spec" >/dev/null 2>&1 \
|| aws s3 ls "$KOPS_STATE_STORE/" | grep -q . \
|| { echo "state store empty; nothing to get" >&2; exit 1; } Type guard
null
Try / catch
if ! out=$(kops get clusters 2>&1); then case "$out" in *"no clusters found"*) echo "state store $KOPS_STATE_STORE has no clusters";; *) echo "$out";; esac fi
Prevention
- Pin KOPS_STATE_STORE per environment in scripts; don't rely on ambient values.
- Run `kops get clusters` once at script start as a precondition check.
- Use full state-store URLs including any prefix used at create time.
When it happens
Trigger: `kops get clusters` (no args, no --name) against a state store containing zero clusters, or filterClustersByName returning an empty match set in the non-strict path.
Common situations: Pointing KOPS_STATE_STORE at a fresh or wrong bucket (e.g. s3://bucket vs s3://bucket/prefix); typo'd state store in another account/region; clusters were deleted; running `kops get` before `kops create cluster`.
Related errors
- error creating cluster: %v
- error querying cluster %q: %v
- error writing additional objects: %v
- cluster %q already exists; use 'kops update cluster' to appl
- error writing updated configuration: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/d0717a792642cb3a.
Report an issue: GitHub.