{"record":{"id":"8fa0d37a2ed9c420","repo":"kubernetes/kops","slug":"cluster-q-already-exists-use-kops-update-cluste","errorCode":null,"errorMessage":"cluster %q already exists; use 'kops update cluster' to apply changes","messagePattern":"cluster %q already exists; use 'kops update cluster' to apply changes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_cluster.go","lineNumber":575,"sourceCode":"\t\treturn err\n\t}\n\n\tif c.ClusterName == \"\" {\n\t\treturn fmt.Errorf(\"--name is required\")\n\t}\n\n\t{\n\t\tcluster, err := clientset.GetCluster(ctx, c.ClusterName)\n\t\tif err != nil {\n\t\t\tif apierrors.IsNotFound(err) {\n\t\t\t\tcluster = nil\n\t\t\t} else {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tif cluster != nil {\n\t\t\treturn fmt.Errorf(\"cluster %q already exists; use 'kops update cluster' to apply changes\", c.ClusterName)\n\t\t}\n\t}\n\n\tif c.OpenstackNetworkID != \"\" {\n\t\tc.NetworkID = c.OpenstackNetworkID\n\t}\n\n\tif featureflag.Azure.Enabled() {\n\t\tif c.CloudProvider == \"azure\" && c.AzureSubscriptionID == \"\" {\n\t\t\treturn fmt.Errorf(\"--azure-subscription-id is required\")\n\t\t}\n\t}\n\n\tclusterResult, err := cloudup.NewCluster(&c.NewClusterOptions, clientset)\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_cluster.go#L557-L593","documentation":"RunCreateCluster looks up the named cluster in the state store; if it already exists (and the lookup wasn't a NotFound error), creation is refused with 'cluster %q already exists'. This prevents accidentally overwriting an existing cluster's configuration via create.","triggerScenarios":"Running `kops create cluster` for a cluster name that already has a cluster spec in the state store, or re-running an idempotent creation script a second time.","commonSituations":"Re-running CI/bootstrap scripts without checking for prior creation; leftover cluster state after a partially deleted cluster; using a generic name that collides with an existing cluster.","solutions":["Use `kops update cluster --name <name> --yes` to apply changes to the existing cluster instead of create","Choose a different cluster name if you truly want a new cluster","Delete the old cluster first with `kops delete cluster --name <name> --yes` if it is no longer needed","Inspect with `kops get clusters` to see what already exists"],"exampleFix":"// before\nkops create cluster mycluster.example.com ...\n// after (cluster exists)\nkops update cluster --name mycluster.example.com --yes","handlingStrategy":"validation","validationCode":"existing, err := clientset.GetCluster(ctx, name)\nif err == nil && existing != nil {\n\t// use update instead of create\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `kops get cluster <name>` before create in idempotent scripts","Branch to `kops update cluster --yes` when the cluster exists","Use unique names per environment to avoid collisions","Clean up stale state store entries after manual deletions"],"tags":["cli","state-store","idempotency"],"backgroundTag":"resource-already-exists","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"}