kubernetes/kops · error
error creating cluster: %v
Error message
error creating cluster: %v
What it means
Wraps a failure of clientset.CreateCluster while `kops replace --force` was creating a brand-new cluster in the state store. The create call (not the config parsing) failed; the underlying API/registry error is carried in %v.
Source
Thrown at cmd/kops/replace.go:150
if errors.IsNotFound(err) {
cluster = nil
} else {
return fmt.Errorf("error fetching cluster %q: %v", clusterName, err)
}
}
if cluster == nil {
if !c.Force {
return fmt.Errorf("cluster %v does not exist (try adding --force flag)", clusterName)
}
err = cloudup.PerformAssignments(v, vfsContext, cloud)
if err != nil {
return fmt.Errorf("error populating configuration: %w", err)
}
_, err = clientset.CreateCluster(ctx, v)
if err != nil {
return fmt.Errorf("error creating cluster: %v", err)
}
} else {
_, err = clientset.UpdateCluster(ctx, v, status)
if err != nil {
return fmt.Errorf("error replacing cluster: %v", err)
}
}
}
case *kopsapi.InstanceGroup:
clusterName := v.ObjectMeta.Labels[kopsapi.LabelClusterName]
if clusterName == "" {
return fmt.Errorf("must specify %q label with cluster name to replace instanceGroup", kopsapi.LabelClusterName)
}
cluster, err := clientset.GetCluster(ctx, clusterName)
if err != nil {
if errors.IsNotFound(err) {
return fmt.Errorf("cluster %q not found", clusterName)View on GitHub (pinned to 4c8573c808)
Solutions
- Check write permissions on the state store bucket/container and credentials
- Re-run with `kops get clusters` to see if the cluster now exists (race) and use replace/update instead
- Validate the manifest spec (`kops replace` decodes strictly; fix invalid fields like kubernetesVersion, networking)
- Confirm the state store is healthy (no lifecycle rules deleting objects, no SSE/KMS access issues)
- Read the wrapped %v error for the exact backend or validation cause
Example fix
// before aws s3api put-object --bucket my-state-store --key test # AccessDenied // after # fix IAM policy to allow s3:PutObject on the state store bucket kops replace -f cluster.yaml --force
Defensive patterns
Strategy: retry
Validate before calling
// ensure state store is writable
key := path.Join(stateStore, "test-write-probe")
if err := writeProbe(stateStore); err != nil {
return fmt.Errorf("state store not writable: %w", err)
} Try / catch
_, err := clientset.CreateCluster(ctx, v)
if err != nil {
if isConflict(err) {
// cluster created concurrently: fall back to update path
} else if isTransient(err) {
// retry with backoff
}
return err
} Prevention
- Grant write (PutObject) permissions for CI/service roles on the state store
- Avoid concurrent create of the same cluster from multiple jobs
- Validate the spec against the supported schema before create
- Watch for bucket lifecycle rules or KMS policies blocking writes
When it happens
Trigger: CreateCluster failing due to an unwritable state store (permissions, quota), an invalid cluster spec rejected by validation, a conflict because the object was concurrently created, or serialization issues with the API version.
Common situations: State store bucket is read-only or credentials lack write access; bucket region/permissions changed; cluster was created by another process between the Get and Create; malformed spec (e.g. invalid kubernetesVersion or networking config).
Related errors
- error storing InstanceGroup: %v
- error replacing cluster: %v
- cluster not found %q
- reading instance groups: %w
- reading file %v: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/b6eab23b100a79ee.
Report an issue: GitHub.