Skip to content

Commit

Permalink
Updates for Terraform (#3293)
Browse files Browse the repository at this point in the history
Lumped a couple of things together:

1. Updated Terraform to the latest release in the build image.
2. Make a fix to the GKE image that ignores the maintenance policy if
the cluster is not on a release channel.
  • Loading branch information
markmandel authored Jul 31, 2023
1 parent 1bffe25 commit 034f38a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ RUN echo "export PATH=/usr/local/go/bin:/go/bin/:\$PATH" >> /root/.bashrc
RUN echo "export EDITOR=nano" >> /root/.bashrc

# install terraform
RUN wget -nv -O terraform.zip https://releases.hashicorp.com/terraform/1.0.8/terraform_1.0.8_linux_amd64.zip && unzip ./terraform.zip && mv terraform /usr/local/bin/
RUN wget -nv -O terraform.zip https://releases.hashicorp.com/terraform/1.5.4/terraform_1.5.4_linux_amd64.zip && unzip ./terraform.zip && mv terraform /usr/local/bin/

# code generation scripts
COPY *.sh /root/
Expand Down
68 changes: 36 additions & 32 deletions install/terraform/modules/gke/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,33 @@ 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 {
project = lookup(var.cluster, "project", "agones")
location = lookup(var.cluster, "location", "us-west1-c")
zone = lookup(var.cluster, "zone", "")
name = lookup(var.cluster, "name", "test-cluster")
machineType = lookup(var.cluster, "machineType", "e2-standard-4")
initialNodeCount = lookup(var.cluster, "initialNodeCount", "4")
enableImageStreaming = lookup(var.cluster, "enableImageStreaming", true)
network = lookup(var.cluster, "network", "default")
subnetwork = lookup(var.cluster, "subnetwork", "")
releaseChannel = lookup(var.cluster, "releaseChannel", "UNSPECIFIED")
kubernetesVersion = lookup(var.cluster, "kubernetesVersion", "1.26")
windowsInitialNodeCount = lookup(var.cluster, "windowsInitialNodeCount", "0")
windowsMachineType = lookup(var.cluster, "windowsMachineType", "e2-standard-4")
autoscale = lookup(var.cluster, "autoscale", false)
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(), "4080h")) # 170 days
project = lookup(var.cluster, "project", "agones")
location = lookup(var.cluster, "location", "us-west1-c")
zone = lookup(var.cluster, "zone", "")
name = lookup(var.cluster, "name", "test-cluster")
machineType = lookup(var.cluster, "machineType", "e2-standard-4")
initialNodeCount = lookup(var.cluster, "initialNodeCount", "4")
enableImageStreaming = lookup(var.cluster, "enableImageStreaming", true)
network = lookup(var.cluster, "network", "default")
subnetwork = lookup(var.cluster, "subnetwork", "")
releaseChannel = lookup(var.cluster, "releaseChannel", "UNSPECIFIED")
kubernetesVersion = lookup(var.cluster, "kubernetesVersion", "1.26")
windowsInitialNodeCount = lookup(var.cluster, "windowsInitialNodeCount", "0")
windowsMachineType = lookup(var.cluster, "windowsMachineType", "e2-standard-4")
autoscale = lookup(var.cluster, "autoscale", false)
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(), "4080h"))
# 170 days
}

data "google_container_engine_versions" "version" {
project = local.project
provider = google-beta
location = local.location
version_prefix = format("%s.",local.kubernetesVersion)
version_prefix = format("%s.", local.kubernetesVersion)
}

# echo command used for debugging purpose
Expand Down Expand Up @@ -85,17 +86,20 @@ resource "google_container_cluster" "primary" {

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" ? [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 Expand Up @@ -245,7 +249,7 @@ resource "google_container_cluster" "primary" {
}
}
dynamic "workload_identity_config" {
for_each = local.workloadIdentity? [1] : []
for_each = local.workloadIdentity ? [1] : []
content {
workload_pool = "${local.project}.svc.id.goog"
}
Expand Down

0 comments on commit 034f38a

Please sign in to comment.