Skip to content

Commit

Permalink
enable queued provisioning on gke nodepool
Browse files Browse the repository at this point in the history
  • Loading branch information
SwarnaBharathiMantena committed Jan 23, 2025
1 parent df2014f commit 31269c6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
10 changes: 6 additions & 4 deletions modules/compute/gke-node-pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,16 @@ limitations under the License.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
| <a name="requirement_google"></a> [google](#requirement\_google) | > 5 |
| <a name="requirement_google-beta"></a> [google-beta](#requirement\_google-beta) | > 5 |
| <a name="requirement_google"></a> [google](#requirement\_google) | > 6.16 |
| <a name="requirement_google-beta"></a> [google-beta](#requirement\_google-beta) | > 6.16 |
| <a name="requirement_null"></a> [null](#requirement\_null) | ~> 3.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | > 5 |
| <a name="provider_google-beta"></a> [google-beta](#provider\_google-beta) | > 5 |
| <a name="provider_google"></a> [google](#provider\_google) | > 6.16 |
| <a name="provider_google-beta"></a> [google-beta](#provider\_google-beta) | > 6.16 |
| <a name="provider_null"></a> [null](#provider\_null) | ~> 3.0 |

## Modules
Expand All @@ -314,6 +314,7 @@ limitations under the License.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_additional_networks"></a> [additional\_networks](#input\_additional\_networks) | Additional network interface details for GKE, if any. Providing additional networks adds additional node networks to the node pool | <pre>list(object({<br/> network = string<br/> subnetwork = string<br/> subnetwork_project = string<br/> network_ip = string<br/> nic_type = string<br/> stack_type = string<br/> queue_count = number<br/> access_config = list(object({<br/> nat_ip = string<br/> network_tier = string<br/> }))<br/> ipv6_access_config = list(object({<br/> network_tier = string<br/> }))<br/> alias_ip_range = list(object({<br/> ip_cidr_range = string<br/> subnetwork_range_name = string<br/> }))<br/> }))</pre> | `[]` | no |
| <a name="input_auto_repair"></a> [auto\_repair](#input\_auto\_repair) | Whether the nodes will be automatically repaired. | `bool` | `true` | no |
| <a name="input_auto_upgrade"></a> [auto\_upgrade](#input\_auto\_upgrade) | Whether the nodes will be automatically upgraded. | `bool` | `false` | no |
| <a name="input_autoscaling_total_max_nodes"></a> [autoscaling\_total\_max\_nodes](#input\_autoscaling\_total\_max\_nodes) | Total maximum number of nodes in the NodePool. | `number` | `1000` | no |
| <a name="input_autoscaling_total_min_nodes"></a> [autoscaling\_total\_min\_nodes](#input\_autoscaling\_total\_min\_nodes) | Total minimum number of nodes in the NodePool. | `number` | `0` | no |
Expand All @@ -322,6 +323,7 @@ limitations under the License.
| <a name="input_disk_size_gb"></a> [disk\_size\_gb](#input\_disk\_size\_gb) | Size of disk for each node. | `number` | `100` | no |
| <a name="input_disk_type"></a> [disk\_type](#input\_disk\_type) | Disk type for each node. | `string` | `null` | no |
| <a name="input_enable_gcfs"></a> [enable\_gcfs](#input\_enable\_gcfs) | Enable the Google Container Filesystem (GCFS). See [restrictions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#gcfs_config). | `bool` | `false` | no |
| <a name="input_enable_queued_provisioning"></a> [enable\_queued\_provisioning](#input\_enable\_queued\_provisioning) | If true, enables Dynamic Workload Scheduler and adds the cloud.google.com/gke-queued taint to the node pool. | `bool` | `false` | no |
| <a name="input_enable_secure_boot"></a> [enable\_secure\_boot](#input\_enable\_secure\_boot) | Enable secure boot for the nodes. Keep enabled unless custom kernel modules need to be loaded. See [here](https://cloud.google.com/compute/shielded-vm/docs/shielded-vm#secure-boot) for more info. | `bool` | `true` | no |
| <a name="input_gke_cluster_exists"></a> [gke\_cluster\_exists](#input\_gke\_cluster\_exists) | A static flag that signals to modules that a cluster has been created. | `bool` | `false` | no |
| <a name="input_gke_version"></a> [gke\_version](#input\_gke\_version) | GKE version | `string` | n/a | yes |
Expand Down
17 changes: 16 additions & 1 deletion modules/compute/gke-node-pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ resource "google_container_node_pool" "node_pool" {
max_pods_per_node = var.max_pods_per_node

management {
auto_repair = true
auto_repair = var.auto_repair
auto_upgrade = var.auto_upgrade
}

Expand All @@ -107,6 +107,13 @@ resource "google_container_node_pool" "node_pool" {
}
}

dynamic "queued_provisioning" {
for_each = var.enable_queued_provisioning ? [1] : []
content {
enabled = true
}
}

node_config {
disk_size_gb = var.disk_size_gb
disk_type = var.disk_type
Expand Down Expand Up @@ -329,6 +336,14 @@ resource "google_container_node_pool" "node_pool" {
condition = var.placement_policy.type != "COMPACT" || local.upgrade_settings.strategy != "BLUE_GREEN"
error_message = "Compact placement is not supported with blue-green upgrades."
}
precondition {
condition = !(var.enable_queued_provisioning == true && var.placement_policy.type == "COMPACT")
error_message = "placement_policy cannot be COMPACT when enable_queued_provisioning is true."
}
precondition {
condition = !(var.enable_queued_provisioning == true && var.reservation_affinity.consume_reservation_type != "NO_RESERVATION")
error_message = "reservation_affinity should be NO_RESERVATION when enable_queued_provisioning is true."
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions modules/compute/gke-node-pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ variable "static_node_count" {
default = null
}

variable "auto_repair" {
description = "Whether the nodes will be automatically repaired."
type = bool
default = true
}

variable "auto_upgrade" {
description = "Whether the nodes will be automatically upgraded."
type = bool
Expand Down Expand Up @@ -421,3 +427,9 @@ variable "run_workload_script" {
type = bool
default = true
}

variable "enable_queued_provisioning" {
description = "If true, enables Dynamic Workload Scheduler and adds the cloud.google.com/gke-queued taint to the node pool."
type = bool
default = false
}
7 changes: 5 additions & 2 deletions modules/compute/gke-node-pool/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "> 5"
version = "> 6.16"
}
google-beta = {
source = "hashicorp/google-beta"
version = "> 5"
version = "> 6.16"
}
null = {
source = "hashicorp/null"
Expand All @@ -32,4 +32,7 @@ terraform {
provider_meta "google" {
module_name = "blueprints/terraform/hpc-toolkit:gke-node-pool/v1.45.0"
}
provider_meta "google-beta" {
module_name = "blueprints/terraform/hpc-toolkit:gke-node-pool/v1.45.0"
}
}

0 comments on commit 31269c6

Please sign in to comment.