agones.dev/agones@v1.53.0/build/terraform/upgrade/module.tf (about) 1 // Copyright 2024 Google LLC All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 16 // Run: 17 // terraform init -backend-config="bucket=<YOUR_GCP_ProjectID>-upgrade-infra-bucket-tfstate" -backend-config="prefix=terraform/state" 18 // terraform apply -var project="<YOUR_GCP_ProjectID>" 19 20 terraform { 21 required_version = ">= 1.0.0" 22 required_providers { 23 google = { 24 source = "hashicorp/google" 25 version = "~> 4.25.0" 26 } 27 helm = { 28 source = "hashicorp/helm" 29 version = "~> 2.3" 30 } 31 } 32 backend "gcs" { 33 } 34 } 35 36 variable "project" {} 37 variable "kubernetes_versions" { 38 description = "Create upgrade test clusters with these k8s versions in these regions" 39 type = map(list(string)) 40 default = { 41 "1.31" = ["us-east1", "RAPID"] 42 "1.32" = ["us-west1", "RAPID"] 43 "1.33" = ["us-central1", "RAPID"] 44 // "1.34" = ["us-east1", "RAPID"] 45 // 46 // Before merge: When adding Kubernetes version 1.{N}, first uncomment the line above. Come back 47 // to these instructions after the update PR merges. 48 // 49 // After merge: After the Kubernetes update PR merges, and all active PRs are updated: 50 // 51 // * Move the 1.{N-3} line to the bottom and comment it out 52 // * Change the (commented out) 1.{N-3} to 1.{N+1} 53 // * You should now have 3 versions uncommented (versions 1.{N-2} .. 1.{N}), 54 // and 1.{N+1} commented out for the next update. The new, commented out 1.{N+1} 55 // should be using the region of the current 1.{N-3}. 56 // 57 // Rationale: We cycle the regions us-east1 -> us-west1 -> us-central1 -> us-east1 as versions 58 // are added, using 3 regions so that the PR adding 1.{N} is in a unique region to 59 // 1.{N-2} .. 1.{N-1}, meaning versions never need to share a region in CI. 60 } 61 } 62 63 module "gke_standard_cluster" { 64 for_each = var.kubernetes_versions 65 source = "./gke-standard" 66 project = var.project 67 kubernetesVersion = each.key 68 location = each.value[0] 69 releaseChannel = each.value[1] 70 } 71 72 module "gke_autopilot_cluster" { 73 for_each = var.kubernetes_versions 74 source = "./gke-autopilot" 75 project = var.project 76 kubernetesVersion = each.key 77 location = each.value[0] 78 releaseChannel = each.value[1] 79 } 80 81 // NOTE: These are the same firewall rules as the e2e tests. If running only the upgrade clusters on 82 // a new project the clusters will need these rules. 83 // resource "google_compute_firewall" "udp" { 84 // name = "gke-game-server-firewall" 85 // project = var.project 86 // network = "default" 87 // 88 // allow { 89 // protocol = "udp" 90 // ports = ["7000-8000"] 91 // } 92 // 93 // target_tags = ["game-server"] 94 // source_ranges = ["0.0.0.0/0"] 95 //} 96 // 97 // resource "google_compute_firewall" "tcp" { 98 // name = "gke-game-server-firewall-tcp" 99 // project = var.project 100 // network = "default" 101 // 102 // allow { 103 // protocol = "tcp" 104 // ports = ["7000-8000"] 105 // } 106 // 107 // target_tags = ["game-server"] 108 // source_ranges = ["0.0.0.0/0"] 109 //}