Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zone random_shuffle causes issues in us-central1 #2031

Open
vcolombo opened this issue Aug 7, 2024 · 1 comment
Open

zone random_shuffle causes issues in us-central1 #2031

vcolombo opened this issue Aug 7, 2024 · 1 comment
Labels
bug Something isn't working Stale

Comments

@vcolombo
Copy link

vcolombo commented Aug 7, 2024

TL;DR

The fix implemented in #19 does not work as expected in us-central1 due to this region having four zones.

Expected behavior

When creating a regional cluster with no zones explicitly defined, all zones within a region should be used.

Observed behavior

In us-central1, because of this region having four zones, the random_shuffle selects three out of four zones. If this list of three out of the four zones changes for any reason, terraform attemps to update the cluster and generates an error: Error: googleapi: Error 400: Cluster location change not allowed.

Terraform Configuration

module "gke_autopilot_private_cluster" {
  depends_on = [google_project_iam_binding.shared_vpc]
  count      = var.public_cluster == false ? 1 : 0
  source     = "terraform-google-modules/kubernetes-engine/google//modules/beta-autopilot-private-cluster"
  version    = "30.2.0"

  project_id                 = var.gcp_project_id
  name                       = var.cluster_name
  regional                   = true
  region                     = var.region
  network_project_id         = var.network_project_id
  network                    = var.network
  subnetwork                 = var.subnetwork
  ip_range_pods              = var.pods_range_name
  ip_range_services          = var.services_range_name
  release_channel            = "STABLE"
  network_tags               = []
  deletion_protection        = false
  create_service_account     = true
  add_cluster_firewall_rules = true
  add_shadow_firewall_rules  = true
  enable_private_endpoint    = true
  enable_private_nodes       = true
  grant_registry_access      = true
  master_ipv4_cidr_block     = var.control_plane_network
  master_authorized_networks = []
}

Terraform Version

Terraform v1.6.6
on darwin_arm64

Additional information

I suggest changing the random_shuffle to set result_count to length(data.google_compute_zones.available[0].names) rather than a static value.

@vcolombo vcolombo added the bug Something isn't working label Aug 7, 2024
Copy link

github-actions bot commented Oct 6, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

1 participant