Skip to content

Commit

Permalink
Merge branch 'main' into arbitrary-counts-lists-2716
Browse files Browse the repository at this point in the history
  • Loading branch information
agones-bot authored Dec 16, 2023
2 parents f71ef71 + a193a5a commit a710c98
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 65 deletions.
13 changes: 8 additions & 5 deletions build/terraform/e2e/gke-autopilot/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ module "gke_cluster" {
source = "../../../../install/terraform/modules/gke-autopilot"

cluster = {
"name" = format("gke-autopilot-e2e-test-cluster-%s", replace(var.kubernetesVersion, ".", "-"))
"project" = var.project
"location" = var.location
"releaseChannel" = var.releaseChannel
"kubernetesVersion" = var.kubernetesVersion
"name" = format("gke-autopilot-e2e-test-cluster-%s", replace(var.kubernetesVersion, ".", "-"))
"project" = var.project
"location" = var.location
"releaseChannel" = var.releaseChannel
"kubernetesVersion" = var.kubernetesVersion
"deletionProtection" = false
"maintenanceExclusionStartTime" = timestamp()
"maintenanceExclusionEndTime" = timeadd(timestamp(), "2640h") # 110 days
}

udpFirewall = false // firewall is created at the project module level
Expand Down
18 changes: 10 additions & 8 deletions build/terraform/e2e/gke-standard/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ module "gke_cluster" {
source = "../../../../install/terraform/modules/gke"

cluster = {
"name" = var.overrideName != "" ? var.overrideName : format("standard-e2e-test-cluster-%s", replace(var.kubernetesVersion, ".", "-"))
"location" = var.location
"releaseChannel" = var.releaseChannel
"machineType" = var.machineType
"initialNodeCount" = var.initialNodeCount
"enableImageStreaming" = true
"project" = var.project
"kubernetesVersion" = var.kubernetesVersion
"name" = var.overrideName != "" ? var.overrideName : format("standard-e2e-test-cluster-%s", replace(var.kubernetesVersion, ".", "-"))
"location" = var.location
"releaseChannel" = var.releaseChannel
"machineType" = var.machineType
"initialNodeCount" = var.initialNodeCount
"enableImageStreaming" = true
"project" = var.project
"kubernetesVersion" = var.kubernetesVersion
"maintenanceExclusionStartTime" = timestamp()
"maintenanceExclusionEndTime" = timeadd(timestamp(), "2640h") # 110 days
}

udpFirewall = false // firewall is created at the project module level
Expand Down
55 changes: 30 additions & 25 deletions install/terraform/modules/gke-autopilot/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ data "google_client_config" "default" {}
# A list of all parameters used in interpolation var.cluster
# Set values to default if not key was not set in original map
locals {
name = lookup(var.cluster, "name", "test-cluster")
project = lookup(var.cluster, "project", "agones")
location = lookup(var.cluster, "location", "us-west1")
network = lookup(var.cluster, "network", "default")
subnetwork = lookup(var.cluster, "subnetwork", "")
releaseChannel = lookup(var.cluster, "releaseChannel", "REGULAR")
kubernetesVersion = lookup(var.cluster, "kubernetesVersion", "1.27")
maintenanceExclusionStartTime = lookup(var.cluster, "maintenanceExclusionStartTime", timestamp())
maintenanceExclusionEndTime = lookup(var.cluster, "maintenanceExclusionEndTime", timeadd(timestamp(), "4080h")) # 170 days
name = lookup(var.cluster, "name", "test-cluster")
project = lookup(var.cluster, "project", "agones")
location = lookup(var.cluster, "location", "us-west1")
network = lookup(var.cluster, "network", "default")
subnetwork = lookup(var.cluster, "subnetwork", "")
releaseChannel = lookup(var.cluster, "releaseChannel", "REGULAR")
kubernetesVersion = lookup(var.cluster, "kubernetesVersion", "1.27")
maintenanceExclusionStartTime = lookup(var.cluster, "maintenanceExclusionStartTime", null)
maintenanceExclusionEndTime = lookup(var.cluster, "maintenanceExclusionEndTime", null)
deletionProtection = lookup(var.cluster, "deletionProtection", true)
}

# echo command used for debugging purpose
Expand All @@ -54,28 +55,32 @@ resource "null_resource" "test-setting-variables" {
resource "google_container_cluster" "primary" {
provider = google-beta # required for node_pool_auto_config.network_tags

name = local.name
project = local.project
location = local.location
network = local.network
subnetwork = local.subnetwork
name = local.name
project = local.project
location = local.location
network = local.network
subnetwork = local.subnetwork
deletion_protection = local.deletionProtection

release_channel {
channel = local.releaseChannel != "" ? local.releaseChannel : "UNSPECIFIED"
}
min_master_version = local.kubernetesVersion

maintenance_policy {
# When exclusions and maintenance windows overlap, exclusions have precedence.
daily_maintenance_window {
start_time = "03:00"
}
maintenance_exclusion{
exclusion_name = format("%s-%s", local.name, "exclusion")
start_time = local.maintenanceExclusionStartTime
end_time = local.maintenanceExclusionEndTime
exclusion_options {
scope = "NO_MINOR_UPGRADES"
dynamic "maintenance_policy" {
for_each = (local.releaseChannel != "UNSPECIFIED" && local.maintenanceExclusionStartTime != null && local.maintenanceExclusionEndTime != null) ? [1] : []
content {
# When exclusions and maintenance windows overlap, exclusions have precedence.
daily_maintenance_window {
start_time = "03:00"
}
maintenance_exclusion {
exclusion_name = format("%s-%s", local.name, "exclusion")
start_time = local.maintenanceExclusionStartTime
end_time = local.maintenanceExclusionEndTime
exclusion_options {
scope = "NO_MINOR_UPGRADES"
}
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions install/terraform/modules/gke-autopilot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ variable "cluster" {
type = map(any)

default = {
"name" = "test-cluster"
"project" = "agones"
"location" = "us-west1"
"network" = "default"
"subnetwork" = ""
"releaseChannel" = "REGULAR"
"kubernetesVersion" = "1.27"
"name" = "test-cluster"
"project" = "agones"
"location" = "us-west1"
"network" = "default"
"subnetwork" = ""
"releaseChannel" = "REGULAR"
"kubernetesVersion" = "1.27"
"deletionProtection" = true
"maintenanceExclusionStartTime" = null
"maintenanceExclusionEndTime" = null
}
}

Expand Down
9 changes: 4 additions & 5 deletions install/terraform/modules/gke/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ locals {
workloadIdentity = lookup(var.cluster, "workloadIdentity", false)
minNodeCount = lookup(var.cluster, "minNodeCount", "1")
maxNodeCount = lookup(var.cluster, "maxNodeCount", "5")
maintenanceExclusionStartTime = lookup(var.cluster, "maintenanceExclusionStartTime", timestamp())
maintenanceExclusionEndTime = lookup(var.cluster, "maintenanceExclusionEndTime", timeadd(timestamp(), "2640h"))
# 110 days
maintenanceExclusionStartTime = lookup(var.cluster, "maintenanceExclusionStartTime", null)
maintenanceExclusionEndTime = lookup(var.cluster, "maintenanceExclusionEndTime", null)
}

data "google_container_engine_versions" "version" {
Expand Down Expand Up @@ -82,15 +81,15 @@ resource "google_container_cluster" "primary" {

networking_mode = "VPC_NATIVE"
ip_allocation_policy {}

release_channel {
channel = local.releaseChannel
}

min_master_version = local.kubernetesVersion

dynamic "maintenance_policy" {
for_each = local.releaseChannel != "UNSPECIFIED" ? [1] : []
for_each = (local.releaseChannel != "UNSPECIFIED" && local.maintenanceExclusionStartTime != null && local.maintenanceExclusionEndTime != null) ? [1] : []
content {
# When exclusions and maintenance windows overlap, exclusions have precedence.
daily_maintenance_window {
Expand Down
32 changes: 17 additions & 15 deletions install/terraform/modules/gke/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ variable "cluster" {
type = map(any)

default = {
"location" = "us-west1-c"
"name" = "test-cluster"
"machineType" = "e2-standard-4"
"initialNodeCount" = "4"
"project" = "agones"
"network" = "default"
"subnetwork" = ""
"releaseChannel" = "UNSPECIFIED"
"kubernetesVersion" = "1.27"
"windowsInitialNodeCount" = "0"
"windowsMachineType" = "e2-standard-4"
"autoscale" = false
"workloadIdentity" = false
"minNodeCount" = "1"
"maxNodeCount" = "5"
"location" = "us-west1-c"
"name" = "test-cluster"
"machineType" = "e2-standard-4"
"initialNodeCount" = "4"
"project" = "agones"
"network" = "default"
"subnetwork" = ""
"releaseChannel" = "UNSPECIFIED"
"kubernetesVersion" = "1.27"
"windowsInitialNodeCount" = "0"
"windowsMachineType" = "e2-standard-4"
"autoscale" = false
"workloadIdentity" = false
"minNodeCount" = "1"
"maxNodeCount" = "5"
"maintenanceExclusionStartTime" = null
"maintenanceExclusionEndTime" = null
}
}

Expand Down

0 comments on commit a710c98

Please sign in to comment.