kubernetes/kops · error

cluster not found %q

Error message

cluster not found %q

What it means

When one or more cluster names are requested explicitly, filterClustersByName builds a name->cluster map and returns 'cluster not found %q' the first time a requested name has no matching cluster in the state store. Unlike the empty-list case, this pinpoints the exact missing name.

Source

Thrown at cmd/kops/get_cluster.go:205

	default:
		return fmt.Errorf("unknown output format: %q", options.Output)
	}
}

// filterClustersByName returns the clusters matching the specified names.
// If names are specified and no cluster is found with a name, we return an error.
func filterClustersByName(clusterNames []string, clusters []*kopsapi.Cluster) ([]*kopsapi.Cluster, error) {
	if len(clusterNames) != 0 {
		// Build a map as we want to return them in the same order as args
		m := make(map[string]*kopsapi.Cluster)
		for _, c := range clusters {
			m[c.ObjectMeta.Name] = c
		}
		var filtered []*kopsapi.Cluster
		for _, clusterName := range clusterNames {
			c := m[clusterName]
			if c == nil {
				return nil, fmt.Errorf("cluster not found %q", clusterName)
			}

			filtered = append(filtered, c)
		}
		return filtered, nil
	}

	return clusters, nil
}

func clusterOutputTable(clusters []*kopsapi.Cluster, out io.Writer) error {
	t := &tables.Table{}
	t.AddColumn("NAME", func(c *kopsapi.Cluster) string {
		return c.ObjectMeta.Name
	})
	t.AddColumn("CLOUD", func(c *kopsapi.Cluster) string {
		return string(c.GetCloudProvider())
	})

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run `kops get clusters` (plural, no args) to list exact cluster names and copy the one you meant.
  2. Use the full cluster name exactly as registered (usually the DNS FQDN), not an alias or partial name.
  3. Confirm KOPS_STATE_STORE points at the store holding that cluster: `kops get clusters --state s3://<bucket>`.
  4. Check `kops export kubecfg` history or the bucket for renames/deletions.

Example fix

// before
kops get cluster mycluster
// after
kops get cluster mycluster.example.com
Defensive patterns

Strategy: validation

Validate before calling

# resolve exact cluster names first
kops get clusters --name "$1" >/dev/null 2>&1 || {
  echo "$1 is not a cluster in $KOPS_STATE_STORE; run: kops get clusters" >&2; exit 1
}
kops get cluster "$1"

Type guard

null

Try / catch

if ! kops get cluster "$CLUSTER" >/dev/null 2>&1; then
  echo "cluster '$CLUSTER' not found — exact names:"
  kops get clusters
fi

Prevention

When it happens

Trigger: `kops get cluster missing.example.com` where the name does not exactly match a cluster's ObjectMeta.Name in the state store.

Common situations: Typos in the cluster FQDN; using a short alias (e.g. 'mycluster') instead of the full DNS name; querying a state store different from the one where the cluster was created; cluster deleted by a teammate.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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