kubernetes/kops · error
cluster %q not found
Error message
cluster %q not found
What it means
RunCreate successfully queried the backend for the labeled cluster but received a nil result, meaning no cluster with that name exists in the state store. kOps surfaces this as a distinct 'not found' message rather than a backend error.
Source
Thrown at cmd/kops/create.go:167
}
return fmt.Errorf("error creating cluster: %v", err)
}
fmt.Fprintf(&sb, "Created cluster/%s\n", v.ObjectMeta.Name)
clusters = append(clusters, v)
// cSpec = true
case *kopsapi.InstanceGroup:
clusterName = v.ObjectMeta.Labels[kopsapi.LabelClusterName]
if clusterName == "" {
return fmt.Errorf("must specify %q label with cluster name to create instanceGroup", kopsapi.LabelClusterName)
}
cluster, err := clientset.GetCluster(ctx, clusterName)
if err != nil {
return fmt.Errorf("error querying cluster %q: %v", clusterName, err)
}
if cluster == nil {
return fmt.Errorf("cluster %q not found", clusterName)
}
_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, v, metav1.CreateOptions{})
if err != nil {
if apierrors.IsAlreadyExists(err) {
return fmt.Errorf("instanceGroup %q already exists", v.ObjectMeta.Name)
}
return fmt.Errorf("error creating instanceGroup: %v", err)
}
fmt.Fprintf(&sb, "Created instancegroup/%s\n", v.ObjectMeta.Name)
case *kopsapi.SSHCredential:
clusterName = v.ObjectMeta.Labels[kopsapi.LabelClusterName]
if clusterName == "" {
return fmt.Errorf("must specify %q label with cluster name to create SSHCredential", kopsapi.LabelClusterName)
}
if v.Spec.PublicKey == "" {
return fmt.Errorf("spec.PublicKey is required")View on GitHub (pinned to 4c8573c808)
Solutions
- Create the cluster first (`kops create -f cluster.yaml`) then create the instance group
- Fix the `kops.k8s.io/cluster` label to match an existing cluster name exactly
- Check with `kops get clusters` which clusters exist in KOPS_STATE_STORE
Example fix
// before labels: kops.k8s.io/cluster: myclster.example.com // after labels: kops.k8s.io/cluster: mycluster.example.com
Defensive patterns
Strategy: validation
Validate before calling
clusterName := ig.Labels[kopsapi.LabelClusterName]
if _, err := clientset.GetCluster(ctx, clusterName); err != nil || clusterName == "" {
return fmt.Errorf("cluster %q does not exist; create it first", clusterName)
} Prevention
- Cross-check the label value against `kops get clusters` output
- Order create operations: cluster before instance groups
- Avoid hand-typing cluster names; source them from the cluster spec
When it happens
Trigger: `kops create -f ig.yaml` where the InstanceGroup's `kops.k8s.io/cluster` label names a cluster that was never created or has been deleted, in the same command run or a prior one.
Common situations: Typo in the cluster label; creating instance groups before `kops create -f cluster.yaml` (both in one -f file where the IG section precedes the Cluster section, or in separate runs); cluster deleted by `kops delete cluster`.
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
- instanceGroup: %v does not exist (try adding --force flag)
- must specify %q label with cluster name to create instanceGr
- instanceGroup %q already exists
- error creating instanceGroup: %v
- InstanceGroup %q not found
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/af5363f663a42ba9.
Report an issue: GitHub.