{"record":{"id":"5a0dddad576a7986","repo":"kubernetes/kops","slug":"error-creating-cluster-v","errorCode":null,"errorMessage":"error creating cluster: %v","messagePattern":"error creating cluster: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create.go","lineNumber":150,"sourceCode":"\t\t\tswitch v := o.(type) {\n\t\t\tcase *kopsapi.Cluster:\n\t\t\t\tcloud, err := cloudup.BuildCloud(v)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\t// Adding a PerformAssignments() call here as the user might be trying to use\n\t\t\t\t// the new `-f` feature, with an old cluster definition.\n\t\t\t\terr = cloudup.PerformAssignments(v, vfsContext, cloud)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error populating configuration: %v\", err)\n\t\t\t\t}\n\t\t\t\t_, err = clientset.CreateCluster(ctx, v)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif apierrors.IsAlreadyExists(err) {\n\t\t\t\t\t\treturn fmt.Errorf(\"cluster %q already exists\", v.ObjectMeta.Name)\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"error creating cluster: %v\", err)\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(&sb, \"Created cluster/%s\\n\", v.ObjectMeta.Name)\n\t\t\t\tclusters = append(clusters, v)\n\t\t\t\t// cSpec = true\n\n\t\t\tcase *kopsapi.InstanceGroup:\n\t\t\t\tclusterName = v.ObjectMeta.Labels[kopsapi.LabelClusterName]\n\t\t\t\tif clusterName == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"must specify %q label with cluster name to create instanceGroup\", kopsapi.LabelClusterName)\n\t\t\t\t}\n\t\t\t\tcluster, err := clientset.GetCluster(ctx, clusterName)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error querying cluster %q: %v\", clusterName, err)\n\t\t\t\t}\n\n\t\t\t\tif cluster == nil {\n\t\t\t\t\treturn fmt.Errorf(\"cluster %q not found\", clusterName)\n\t\t\t\t}","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create.go#L132-L168","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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"],"exampleFix":"// before\nexport KOPS_STATE_STORE=s3://wrong-bucket\n// after\nexport KOPS_STATE_STORE=s3://my-kops-state-store","handlingStrategy":"try-catch","validationCode":"// verify state store writable before create\nu, err := url.Parse(os.Getenv(\"KOPS_STATE_STORE\"))\nif err != nil || u.Scheme == \"\" {\n    return fmt.Errorf(\"KOPS_STATE_STORE invalid or unset\")\n}\nif err := probeWriteAccess(u); err != nil {\n    return fmt.Errorf(\"state store not writable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"_, err := clientset.CreateCluster(ctx, v)\nif err != nil {\n    if !apierrors.IsAlreadyExists(err) {\n        log.Printf(\"create failed: %v — check KOPS_STATE_STORE, credentials, network\", err)\n        return fmt.Errorf(\"error creating cluster: %v\", err)\n    }\n}","preventionTips":["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"],"tags":["cli","state-store","cluster-lifecycle"],"backgroundTag":"state-store-unavailable","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}