Skip to content

Commit

Permalink
Merge branch 'master' into gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody authored May 20, 2024
2 parents 53374c7 + 2272164 commit ba9e3d6
Show file tree
Hide file tree
Showing 46 changed files with 547 additions and 138 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module "gke" {
network_policy = false
horizontal_pod_autoscaling = true
filestore_csi_driver = false
dns_cache = false
node_pools = [
{
Expand Down Expand Up @@ -137,7 +138,7 @@ Then perform the following commands on the root folder:
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
| additional\_ip\_range\_pods | List of _names_ of the additional secondary subnet ip ranges to use for pods | `list(string)` | `[]` | no |
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> image_type = optional(string)<br> strategy = optional(string)<br> max_surge = optional(number)<br> max_unavailable = optional(number)<br> node_pool_soak_duration = optional(string)<br> batch_soak_duration = optional(string)<br> batch_percentage = optional(number)<br> batch_node_count = optional(number)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "image_type": "COS_CONTAINERD",<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED (default) or CLUSTER\_SCOPE or VPC\_SCOPE. | `string` | `"DNS_SCOPE_UNSPECIFIED"` | no |
Expand Down Expand Up @@ -242,6 +243,7 @@ Then perform the following commands on the root folder:
|------|-------------|
| ca\_certificate | Cluster ca certificate (base64 encoded) |
| cluster\_id | Cluster ID |
| dns\_cache\_enabled | Whether DNS Cache enabled |
| endpoint | Cluster endpoint |
| fleet\_membership | Fleet membership (if registered) |
| gateway\_api\_channel | The gateway api channel of this cluster. |
Expand Down Expand Up @@ -324,6 +326,7 @@ The node_pools variable takes the following parameters:
| value | The value for the taint | | Required |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional |

## windows_node_pools variable
The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
Expand Down
3 changes: 2 additions & 1 deletion autogen/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ module "gke" {
{% if beta_cluster and autopilot_cluster != true %}
istio = true
cloudrun = true
dns_cache = false
{% endif %}
dns_cache = false
{% if autopilot_cluster != true %}
node_pools = [
Expand Down Expand Up @@ -251,6 +251,7 @@ The node_pools variable takes the following parameters:
| value | The value for the taint | | Required |
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
| location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional |

## windows_node_pools variable
The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.
Expand Down
30 changes: 30 additions & 0 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,30 @@ resource "google_container_cluster" "primary" {
disk_size = lookup(var.cluster_autoscaling, "disk_size", 100)
disk_type = lookup(var.cluster_autoscaling, "disk_type", "pd-standard")

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)
}
}
}
}

{% if beta_cluster %}
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
{% endif %}

image_type = lookup(var.cluster_autoscaling, "image_type", "COS_CONTAINERD")
}
}
autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED"
Expand Down Expand Up @@ -865,6 +886,15 @@ resource "google_container_node_pool" "windows_pools" {
}
}

# Supports a single secondary boot disk because `map(any)` must have the same values type.
dynamic "secondary_boot_disks" {
for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : []
content {
disk_image = secondary_boot_disks.value
mode = "CONTAINER_IMAGE_CACHE"
}
}

service_account = lookup(
each.value,
"service_account",
Expand Down
2 changes: 1 addition & 1 deletion autogen/main/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ locals {
{% if beta_cluster %}
# BETA features
cluster_istio_enabled = ! local.cluster_output_istio_disabled
cluster_dns_cache_enabled = var.dns_cache
{% if autopilot_cluster != true %}
cluster_telemetry_type_is_set = var.cluster_telemetry_type != null
{% endif %}
Expand All @@ -242,6 +241,7 @@ locals {
# /BETA features
{% endif %}

cluster_dns_cache_enabled = var.dns_cache
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
}
Expand Down
10 changes: 5 additions & 5 deletions autogen/main/outputs.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ output "peering_name" {
value = local.cluster_peering_name
}
{% endif %}

output "dns_cache_enabled" {
description = "Whether DNS Cache enabled"
value = local.cluster_dns_cache_enabled
}
{% if beta_cluster %}

output "cloudrun_enabled" {
Expand All @@ -214,11 +219,6 @@ output "istio_enabled" {
value = local.cluster_istio_enabled
}

output "dns_cache_enabled" {
description = "Whether DNS Cache enabled"
value = local.cluster_dns_cache_enabled
}

output "pod_security_policy_enabled" {
description = "Whether pod security policy is enabled"
value = local.cluster_pod_security_policy_enabled
Expand Down
31 changes: 20 additions & 11 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,25 @@ variable "enable_resource_consumption_export" {
{% if autopilot_cluster != true %}
variable "cluster_autoscaling" {
type = object({
enabled = bool
autoscaling_profile = string
min_cpu_cores = number
max_cpu_cores = number
min_memory_gb = number
max_memory_gb = number
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
auto_repair = bool
auto_upgrade = bool
disk_size = optional(number)
disk_type = optional(string)
enabled = bool
autoscaling_profile = string
min_cpu_cores = number
max_cpu_cores = number
min_memory_gb = number
max_memory_gb = number
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
auto_repair = bool
auto_upgrade = bool
disk_size = optional(number)
disk_type = optional(string)
image_type = optional(string)
strategy = optional(string)
max_surge = optional(number)
max_unavailable = optional(number)
node_pool_soak_duration = optional(string)
batch_soak_duration = optional(string)
batch_percentage = optional(number)
batch_node_count = optional(number)
})
default = {
enabled = false
Expand All @@ -268,6 +276,7 @@ variable "cluster_autoscaling" {
auto_upgrade = true
disk_size = 100
disk_type = "pd-standard"
image_type = "COS_CONTAINERD"
}
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
}
Expand Down
39 changes: 39 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,27 @@ resource "google_container_cluster" "primary" {
disk_size = lookup(var.cluster_autoscaling, "disk_size", 100)
disk_type = lookup(var.cluster_autoscaling, "disk_type", "pd-standard")

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)
}
}
}
}


image_type = lookup(var.cluster_autoscaling, "image_type", "COS_CONTAINERD")
}
}
autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED"
Expand Down Expand Up @@ -582,6 +603,15 @@ resource "google_container_node_pool" "pools" {
}
}

# Supports a single secondary boot disk because `map(any)` must have the same values type.
dynamic "secondary_boot_disks" {
for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : []
content {
disk_image = secondary_boot_disks.value
mode = "CONTAINER_IMAGE_CACHE"
}
}

service_account = lookup(
each.value,
"service_account",
Expand Down Expand Up @@ -798,6 +828,15 @@ resource "google_container_node_pool" "windows_pools" {
}
}

# Supports a single secondary boot disk because `map(any)` must have the same values type.
dynamic "secondary_boot_disks" {
for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : []
content {
disk_image = secondary_boot_disks.value
mode = "CONTAINER_IMAGE_CACHE"
}
}

service_account = lookup(
each.value,
"service_account",
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ locals {
}] : []


cluster_dns_cache_enabled = var.dns_cache
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
}
Expand Down
1 change: 1 addition & 0 deletions modules/beta-autopilot-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module "gke" {
enable_private_endpoint = true
enable_private_nodes = true
master_ipv4_cidr_block = "10.0.0.0/28"
dns_cache = false
}
```
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ locals {

# BETA features
cluster_istio_enabled = !local.cluster_output_istio_disabled
cluster_dns_cache_enabled = var.dns_cache
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled

# /BETA features

cluster_dns_cache_enabled = var.dns_cache
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
}
Expand Down
10 changes: 5 additions & 5 deletions modules/beta-autopilot-private-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ output "peering_name" {
value = local.cluster_peering_name
}

output "dns_cache_enabled" {
description = "Whether DNS Cache enabled"
value = local.cluster_dns_cache_enabled
}

output "cloudrun_enabled" {
description = "Whether CloudRun enabled"
value = false
Expand All @@ -169,11 +174,6 @@ output "istio_enabled" {
value = local.cluster_istio_enabled
}

output "dns_cache_enabled" {
description = "Whether DNS Cache enabled"
value = local.cluster_dns_cache_enabled
}

output "pod_security_policy_enabled" {
description = "Whether pod security policy is enabled"
value = local.cluster_pod_security_policy_enabled
Expand Down
1 change: 1 addition & 0 deletions modules/beta-autopilot-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module "gke" {
ip_range_services = "us-central1-01-gke-01-services"
horizontal_pod_autoscaling = true
filestore_csi_driver = false
dns_cache = false

}
```
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-public-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ locals {

# BETA features
cluster_istio_enabled = !local.cluster_output_istio_disabled
cluster_dns_cache_enabled = var.dns_cache
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled

# /BETA features

cluster_dns_cache_enabled = var.dns_cache
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
}
Expand Down
10 changes: 5 additions & 5 deletions modules/beta-autopilot-public-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ output "tpu_ipv4_cidr_block" {



output "dns_cache_enabled" {
description = "Whether DNS Cache enabled"
value = local.cluster_dns_cache_enabled
}

output "cloudrun_enabled" {
description = "Whether CloudRun enabled"
value = false
Expand All @@ -159,11 +164,6 @@ output "istio_enabled" {
value = local.cluster_istio_enabled
}

output "dns_cache_enabled" {
description = "Whether DNS Cache enabled"
value = local.cluster_dns_cache_enabled
}

output "pod_security_policy_enabled" {
description = "Whether pod security policy is enabled"
value = local.cluster_pod_security_policy_enabled
Expand Down
Loading

0 comments on commit ba9e3d6

Please sign in to comment.