terraform-google-kubernetes-engine icon indicating copy to clipboard operation
terraform-google-kubernetes-engine copied to clipboard

Add upgrade_settings for NAP created node pools

Open dhoeric opened this issue 1 year ago • 1 comments

TL;DR

The module is missing upgrade_settings on cluster_autoscaling > auto_provisioning_defaults under cluster configuration.

Adding upgrade_settings allow us to fine tune the upgrade behaviour of NAP created node pools.

Terraform Resources

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#upgrade_settings

Detailed design

Add followings on google_container_cluster resource

cluster_autoscaling {
  auto_provisioning_defaults {
    ...

    upgrade_settings {
      strategy        = lookup(var.cluster_autoscaling, "strategy", "SURGE")
      max_surge       = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_surge", 0) : null
      max_unavailable = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_unavailable", 0) : null

      dynamic "blue_green_settings" {
        for_each = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "BLUE_GREEN" ? [1] : []
        content {
          node_pool_soak_duration = lookup(var.cluster_autoscaling, "node_pool_soak_duration", null)

          standard_rollout_policy {
            batch_soak_duration = lookup(var.cluster_autoscaling, "batch_soak_duration", null)
            batch_percentage    = lookup(var.cluster_autoscaling, "batch_percentage", null)
            batch_node_count    = lookup(var.cluster_autoscaling, "batch_node_count", null)
          }
        }
      }
    }
  }
}


### Additional information

_No response_

dhoeric avatar Mar 19 '24 15:03 dhoeric