{"record":{"id":"60f8f9d4cb1f55d7","repo":"kubernetes/kops","slug":"found-multiple-gcp-regions-for-cluster","errorCode":null,"errorMessage":"found multiple gcp regions for cluster","messagePattern":"found multiple gcp regions for cluster","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/controllers/clusterapi/cluster_controller.go","lineNumber":124,"sourceCode":"\t}\n\treturn nil\n}\n\nfunc (s *clusterScope) applyGCPCluster(ctx context.Context, kube client.Client) error {\n\t// This is because of network tags in cloud-provider-gcp\n\t// TODO: cloud-provider-gcp should not assume cluster name is a valid prefix\n\tname := gce.SafeClusterName(s.Cluster.GetName())\n\n\tgcpProject := s.Cluster.Spec.Project\n\tif gcpProject == \"\" {\n\t\treturn fmt.Errorf(\"unable to determine gcp project for cluster\")\n\t}\n\tgcpRegion := \"\"\n\tfor _, subnet := range s.Cluster.Spec.Subnets {\n\t\tif gcpRegion == \"\" {\n\t\t\tgcpRegion = subnet.Region\n\t\t} else if gcpRegion != subnet.Region {\n\t\t\treturn fmt.Errorf(\"found multiple gcp regions for cluster\")\n\t\t}\n\t}\n\tif gcpRegion == \"\" {\n\t\treturn fmt.Errorf(\"unable to determine gcp region for cluster\")\n\t}\n\n\t// TODO: Sync with LinkToNetwork\n\tgcpNetworkName := s.Cluster.Spec.NetworkID\n\tif gcpNetworkName == \"\" {\n\t\tgcpNetworkName = gce.SafeTruncatedClusterName(s.Cluster.ObjectMeta.Name, 63)\n\t}\n\tif gcpNetworkName == \"\" {\n\t\treturn fmt.Errorf(\"unable to determine gcp network for cluster\")\n\t}\n\n\tobj := map[string]any{\n\t\t\"apiVersion\": \"infrastructure.cluster.x-k8s.io/v1beta1\",\n\t\t\"kind\":       \"GCPCluster\",","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/controllers/clusterapi/cluster_controller.go#L106-L142","documentation":"applyGCPCluster derives a single GCP region from the cluster subnets and rejects clusters whose subnets span more than one region, since a GCPCluster object is region-scoped. When two or more subnets have different Region values, reconciliation fails with this error.","triggerScenarios":"clusterScope.Apply() iterating Cluster.Spec.Subnets finds subnet[0].Region != subnet[i].Region for any i.","commonSituations":"Multi-region GCP cluster specs fed into the CAPI controller; copy-paste of subnet definitions from multi-region clusters; editing subnets to add a region for HA without understanding CAPI's single-region constraint.","solutions":["Make all subnets belong to the same GCP region","Split the multi-region deployment into separate clusters per region","Fix the subnet region values if they were set incorrectly"],"exampleFix":"// before\nsubnets:\n- name: us-west1\n  region: us-west1\n- name: us-east1\n  region: us-east1\n// after\nsubnets:\n- name: us-west1\n  region: us-west1\n- name: us-west1-b\n  region: us-west1","handlingStrategy":"validation","validationCode":"regions := map[string]bool{}\nfor _, s := range cluster.Spec.Subnets {\n\tregions[s.Region] = true\n}\nif len(regions) > 1 {\n\treturn fmt.Errorf(\"CAPI GCP clusters must be single-region; found %d regions\", len(regions))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all subnets of a CAPI-managed GCP cluster in one region","Split multi-region topologies across separate clusters","Validate region consistency before applying manifests"],"tags":["gcp","clusterapi","region"],"backgroundTag":"multiple-gcp-regions","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"}