kubernetes/kops · error
error creating cluster: %v
Error message
error creating cluster: %v
What it means
When clientset.CreateCluster fails for any reason other than AlreadyExists, RunCreate wraps it as "error creating cluster: %v". This covers registry/storage-layer failures while persisting the cluster definition.
Source
Thrown at cmd/kops/create.go:150
switch v := o.(type) {
case *kopsapi.Cluster:
cloud, err := cloudup.BuildCloud(v)
if err != nil {
return err
}
// Adding a PerformAssignments() call here as the user might be trying to use
// the new `-f` feature, with an old cluster definition.
err = cloudup.PerformAssignments(v, vfsContext, cloud)
if err != nil {
return fmt.Errorf("error populating configuration: %v", err)
}
_, err = clientset.CreateCluster(ctx, v)
if err != nil {
if apierrors.IsAlreadyExists(err) {
return fmt.Errorf("cluster %q already exists", v.ObjectMeta.Name)
}
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)
}View on GitHub (pinned to 4c8573c808)
Solutions
- Read the wrapped inner error and fix the state store access issue (credentials, bucket existence, permissions)
- Verify KOPS_STATE_STORE is set correctly and the bucket is writable
- Retry after network issues; check `kops get clusters` to inspect store health
- If the object is rejected by validation, correct the spec and re-run create
Example fix
// before export KOPS_STATE_STORE=s3://wrong-bucket // after export KOPS_STATE_STORE=s3://my-kops-state-store
Defensive patterns
Strategy: try-catch
Validate before calling
// verify state store writable before create
u, err := url.Parse(os.Getenv("KOPS_STATE_STORE"))
if err != nil || u.Scheme == "" {
return fmt.Errorf("KOPS_STATE_STORE invalid or unset")
}
if err := probeWriteAccess(u); err != nil {
return fmt.Errorf("state store not writable: %v", err)
} Try / catch
_, err := clientset.CreateCluster(ctx, v)
if err != nil {
if !apierrors.IsAlreadyExists(err) {
log.Printf("create failed: %v — check KOPS_STATE_STORE, credentials, network", err)
return fmt.Errorf("error creating cluster: %v", err)
}
} Prevention
- Verify KOPS_STATE_STORE and bucket permissions before create
- Run `kops get clusters` as a connectivity smoke test
- Ensure storage credentials (AWS/GCS) have write access to the bucket
- Enable bucket versioning and monitor state store availability
When it happens
Trigger: `kops create -f` where the state store backend is unreachable, unwritable, misconfigured, or the registry rejects the cluster object (e.g. validation or backend error).
Common situations: Wrong KOPS_STATE_STORE URL; missing cloud/storage credentials (S3/GCS write denied); state store bucket missing or versioning misconfigured; network outage; invalid object rejected by the registry after decode succeeded.
Related errors
- cluster %q already exists
- 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/5a0dddad576a7986.
Report an issue: GitHub.