kubernetes/kops · error

cluster not found %q

Error message

cluster not found %q

What it means

RunToolboxDump (kops toolbox dump) calls clientset.GetCluster and, like GetCluster in root.go, receives a nil cluster with nil error when the cluster is absent from the state store. This explicit check converts that into 'cluster not found'. The dump cannot proceed without the cluster spec because it needs it to build the cloud provider.

Source

Thrown at cmd/kops/toolbox_dump.go:136

	cmd.Flags().StringVar(&options.SSHUser, "ssh-user", options.SSHUser, "The remote user for SSH access to instances")
	cmd.RegisterFlagCompletionFunc("ssh-user", cobra.NoFileCompletions)

	return cmd
}

func RunToolboxDump(ctx context.Context, f commandutils.Factory, out io.Writer, options *ToolboxDumpOptions) error {
	clientset, err := f.KopsClient()
	if err != nil {
		return err
	}

	cluster, err := clientset.GetCluster(ctx, options.ClusterName)
	if err != nil {
		return err
	}

	if cluster == nil {
		return fmt.Errorf("cluster not found %q", options.ClusterName)
	}

	cloud, err := cloudup.BuildCloud(cluster)
	if err != nil {
		return err
	}

	var cloudResources *resources.Dump
	if options.CloudResources {
		resourceMap, err := resourceops.ListResources(cloud, cluster)
		if err != nil {
			return err
		}
		d, err := resources.BuildDump(ctx, cloud, resourceMap)
		if err != nil {
			return err
		}
		cloudResources = d

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run kops get clusters to confirm the exact name and use it verbatim with --name.
  2. Fix KOPS_STATE_STORE (or --state) to the bucket that actually holds the cluster.
  3. Include the full DNS name, e.g. --name mycluster.k8s.local for gossip clusters.
  4. If the cluster was intentionally deleted, there is nothing to dump — verify against the correct environment.

Example fix

// before
kops toolbox dump --name prod   # not found
// after
kops toolbox dump --name prod.k8s.local --state s3://my-state-bucket
Defensive patterns

Strategy: validation

Validate before calling

kops get cluster "$CLUSTER_NAME" >/dev/null 2>&1 || { echo "cluster $CLUSTER_NAME not found"; exit 1; }
kops toolbox dump --name "$CLUSTER_NAME"

Try / catch

cluster, err := clientset.GetCluster(ctx, options.ClusterName)
if err != nil {
    return fmt.Errorf("getting cluster %q: %w", options.ClusterName, err)
}
if cluster == nil {
    return fmt.Errorf("cluster %q not found; check --name and KOPS_STATE_STORE", options.ClusterName)
}

Prevention

When it happens

Trigger: Running `kops toolbox dump --name <cluster>` where no cluster object with that name exists in the state store at options.ClusterName.

Common situations: Typoed or partial cluster name on the toolbox dump command; KOPS_STATE_STORE pointing at the wrong bucket/region; cluster was deleted but its name lingers in old kubeconfig or shell history; gossip cluster name missing the .k8s.local suffix.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/db77c6a256f35044. Report an issue: GitHub.