Skip to content

Commit 75629f2

Browse files
authored
Merge branch 'main' into feat/2264/cgroupv2
2 parents 54116c1 + adaabbf commit 75629f2

File tree

36 files changed

+543
-27
lines changed

36 files changed

+543
-27
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Then perform the following commands on the root folder:
180180
| enable\_shielded\_nodes | Enable Shielded Nodes features on all nodes in this cluster | `bool` | `true` | no |
181181
| enable\_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | `bool` | `false` | no |
182182
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | `bool` | `false` | no |
183+
| enterprise\_config | (Optional) Enable or disable GKE enterprise. Valid values are DEFAULT and ENTERPRISE. | `string` | `null` | no |
183184
| filestore\_csi\_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | `bool` | `false` | no |
184185
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers. Either flag `add_master_webhook_firewall_rules` or `add_cluster_firewall_rules` (also adds egress rules) must be set to `true` for inbound-ports firewall rules to be applied. | `list(string)` | <pre>[<br> "8443",<br> "9443",<br> "15017"<br>]</pre> | no |
185186
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |
@@ -356,6 +357,7 @@ The node_pools variable takes the following parameters:
356357
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | | Optional |
357358
| pod_range | The name of the secondary range for pod IPs. | | Optional |
358359
| enable_private_nodes | Whether nodes have internal IP addresses only. | | Optional |
360+
| node_affinity | The node affinty in the format `"{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}"`. | | Optional |
359361
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
360362
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
361363
| node_metadata | Options to expose the node metadata to the workload running on the node | | Optional |

autogen/main/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ The node_pools variable takes the following parameters:
245245
{% if not private_cluster %}
246246
| enable_private_nodes | Whether nodes have internal IP addresses only. | | Optional |
247247
{% endif %}
248+
| node_affinity | The node affinty in the format `"{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"node-group-name\"]}"`. | | Optional |
248249
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
249250
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
250251
| node_metadata | Options to expose the node metadata to the workload running on the node | | Optional |

autogen/main/cluster.tf.tmpl

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ resource "google_container_cluster" "primary" {
260260
}
261261
}
262262

263+
dynamic "enterprise_config" {
264+
for_each = var.enterprise_config != null ? [1] : []
265+
content {
266+
desired_tier = var.enterprise_config
267+
}
268+
}
269+
263270
enable_fqdn_network_policy = var.enable_fqdn_network_policy
264271
{% if autopilot_cluster %}
265272
enable_autopilot = true
@@ -571,6 +578,21 @@ resource "google_container_cluster" "primary" {
571578
}
572579
}
573580

581+
dynamic "sole_tenant_config" {
582+
# node_affinity is currently the only member of sole_tenant_config
583+
for_each = lookup(var.node_pools[0], "node_affinity", null) != null ? [true] : []
584+
content {
585+
dynamic "node_affinity" {
586+
for_each = lookup(var.node_pools[0], "node_affinity", null) != null ? [lookup(var.node_pools[0], "node_affinity", null)] : []
587+
content {
588+
key = lookup(jsondecode(node_affinity.value), "key", null)
589+
operator = lookup(jsondecode(node_affinity.value), "operator", null)
590+
values = lookup(jsondecode(node_affinity.value), "values", [])
591+
}
592+
}
593+
}
594+
}
595+
574596
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
575597

576598
tags = concat(
@@ -882,7 +904,7 @@ resource "google_container_node_pool" "windows_pools" {
882904
}
883905

884906
dynamic "network_config" {
885-
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
907+
for_each = length(lookup(each.value, "pod_range", "")) > 0 || {% if private_cluster %}var.enable_private_nodes != null{% else %}lookup(each.value, "enable_private_nodes", null) != null{% endif %} ? [each.value] : []
886908
content {
887909
pod_range = lookup(network_config.value, "pod_range", null)
888910
{% if private_cluster %}
@@ -1100,6 +1122,21 @@ resource "google_container_node_pool" "windows_pools" {
11001122
pod_pids_limit = lookup(each.value, "pod_pids_limit", null)
11011123
}
11021124
}
1125+
1126+
dynamic "sole_tenant_config" {
1127+
# node_affinity is currently the only member of sole_tenant_config
1128+
for_each = lookup(each.value, "node_affinity", null) != null ? [true] : []
1129+
content {
1130+
dynamic "node_affinity" {
1131+
for_each = lookup(each.value, "node_affinity", null) != null ? [lookup(each.value, "node_affinity", null)] : []
1132+
content {
1133+
key = lookup(jsondecode(node_affinity.value), "key", null)
1134+
operator = lookup(jsondecode(node_affinity.value), "operator", null)
1135+
values = lookup(jsondecode(node_affinity.value), "values", [])
1136+
}
1137+
}
1138+
}
1139+
}
11031140
{% if beta_cluster %}
11041141

11051142
dynamic "sandbox_config" {

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,3 +1054,9 @@ variable "monitoring_metric_writer_role" {
10541054
error_message = "The monitoring_metric_writer_role must be either a predefined role (roles/*) or a custom role (projects/*/roles/*)."
10551055
}
10561056
}
1057+
1058+
variable "enterprise_config" {
1059+
description = "(Optional) Enable or disable GKE enterprise. Valid values are DEFAULT and ENTERPRISE."
1060+
type = string
1061+
default = null
1062+
}

cluster.tf

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ resource "google_container_cluster" "primary" {
199199
}
200200
}
201201

202+
dynamic "enterprise_config" {
203+
for_each = var.enterprise_config != null ? [1] : []
204+
content {
205+
desired_tier = var.enterprise_config
206+
}
207+
}
208+
202209
enable_fqdn_network_policy = var.enable_fqdn_network_policy
203210
dynamic "master_authorized_networks_config" {
204211
for_each = var.gcp_public_cidrs_access_enabled != null || length(var.master_authorized_networks) > 0 ? [true] : []
@@ -441,6 +448,21 @@ resource "google_container_cluster" "primary" {
441448
}
442449
}
443450

451+
dynamic "sole_tenant_config" {
452+
# node_affinity is currently the only member of sole_tenant_config
453+
for_each = lookup(var.node_pools[0], "node_affinity", null) != null ? [true] : []
454+
content {
455+
dynamic "node_affinity" {
456+
for_each = lookup(var.node_pools[0], "node_affinity", null) != null ? [lookup(var.node_pools[0], "node_affinity", null)] : []
457+
content {
458+
key = lookup(jsondecode(node_affinity.value), "key", null)
459+
operator = lookup(jsondecode(node_affinity.value), "operator", null)
460+
values = lookup(jsondecode(node_affinity.value), "values", [])
461+
}
462+
}
463+
}
464+
}
465+
444466
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
445467

446468
tags = concat(
@@ -595,7 +617,7 @@ resource "google_container_node_pool" "pools" {
595617
}
596618

597619
dynamic "network_config" {
598-
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
620+
for_each = length(lookup(each.value, "pod_range", "")) > 0 || lookup(each.value, "enable_private_nodes", null) != null ? [each.value] : []
599621
content {
600622
pod_range = lookup(network_config.value, "pod_range", null)
601623
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", null)
@@ -802,6 +824,21 @@ resource "google_container_node_pool" "pools" {
802824
}
803825
}
804826

827+
dynamic "sole_tenant_config" {
828+
# node_affinity is currently the only member of sole_tenant_config
829+
for_each = lookup(each.value, "node_affinity", null) != null ? [true] : []
830+
content {
831+
dynamic "node_affinity" {
832+
for_each = lookup(each.value, "node_affinity", null) != null ? [lookup(each.value, "node_affinity", null)] : []
833+
content {
834+
key = lookup(jsondecode(node_affinity.value), "key", null)
835+
operator = lookup(jsondecode(node_affinity.value), "operator", null)
836+
values = lookup(jsondecode(node_affinity.value), "values", [])
837+
}
838+
}
839+
}
840+
}
841+
805842
dynamic "linux_node_config" {
806843
for_each = length(merge(
807844
local.node_pools_linux_node_configs_sysctls["all"],
@@ -896,7 +933,7 @@ resource "google_container_node_pool" "windows_pools" {
896933
}
897934

898935
dynamic "network_config" {
899-
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
936+
for_each = length(lookup(each.value, "pod_range", "")) > 0 || lookup(each.value, "enable_private_nodes", null) != null ? [each.value] : []
900937
content {
901938
pod_range = lookup(network_config.value, "pod_range", null)
902939
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", null)
@@ -1103,6 +1140,21 @@ resource "google_container_node_pool" "windows_pools" {
11031140
}
11041141
}
11051142

1143+
dynamic "sole_tenant_config" {
1144+
# node_affinity is currently the only member of sole_tenant_config
1145+
for_each = lookup(each.value, "node_affinity", null) != null ? [true] : []
1146+
content {
1147+
dynamic "node_affinity" {
1148+
for_each = lookup(each.value, "node_affinity", null) != null ? [lookup(each.value, "node_affinity", null)] : []
1149+
content {
1150+
key = lookup(jsondecode(node_affinity.value), "key", null)
1151+
operator = lookup(jsondecode(node_affinity.value), "operator", null)
1152+
values = lookup(jsondecode(node_affinity.value), "values", [])
1153+
}
1154+
}
1155+
}
1156+
}
1157+
11061158

11071159
boot_disk_kms_key = lookup(each.value, "boot_disk_kms_key", "")
11081160

examples/node_pool/main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ module "gke" {
9898
node_count = 1
9999
enable_nested_virtualization = true
100100
},
101+
{
102+
name = "pool-06"
103+
node_count = 1
104+
machine_type = "n1-highmem-96"
105+
node_affinity = "{\"key\": \"compute.googleapis.com/node-group-name\", \"operator\": \"IN\", \"values\": [\"${google_compute_node_group.soletenant-nodes.name}\"]}"
106+
},
101107
]
102108

103109
node_pools_metadata = {
@@ -158,3 +164,18 @@ module "gke" {
158164
pool-01 = "CGROUP_MODE_V2"
159165
}
160166
}
167+
168+
resource "google_compute_node_template" "soletenant-tmpl" {
169+
name = "soletenant-tmpl-${var.cluster_name_suffix}"
170+
region = var.region
171+
172+
node_type = "n1-node-96-624"
173+
}
174+
175+
resource "google_compute_node_group" "soletenant-nodes" {
176+
name = "soletenant-node-group-${var.cluster_name_suffix}"
177+
zone = var.zones[0]
178+
179+
initial_size = 1
180+
node_template = google_compute_node_template.soletenant-tmpl.id
181+
}

modules/beta-autopilot-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Then perform the following commands on the root folder:
101101
| enable\_secret\_manager\_addon | Enable the Secret Manager add-on for this cluster | `bool` | `false` | no |
102102
| enable\_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | `bool` | `false` | no |
103103
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | `bool` | `true` | no |
104+
| enterprise\_config | (Optional) Enable or disable GKE enterprise. Valid values are DEFAULT and ENTERPRISE. | `string` | `null` | no |
104105
| filestore\_csi\_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | `bool` | `false` | no |
105106
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers. Either flag `add_master_webhook_firewall_rules` or `add_cluster_firewall_rules` (also adds egress rules) must be set to `true` for inbound-ports firewall rules to be applied. | `list(string)` | <pre>[<br> "8443",<br> "9443",<br> "15017"<br>]</pre> | no |
106107
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |

modules/beta-autopilot-private-cluster/cluster.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ resource "google_container_cluster" "primary" {
119119
}
120120
}
121121

122+
dynamic "enterprise_config" {
123+
for_each = var.enterprise_config != null ? [1] : []
124+
content {
125+
desired_tier = var.enterprise_config
126+
}
127+
}
128+
122129
enable_fqdn_network_policy = var.enable_fqdn_network_policy
123130
enable_autopilot = true
124131
dynamic "master_authorized_networks_config" {

modules/beta-autopilot-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,3 +622,9 @@ variable "monitoring_metric_writer_role" {
622622
error_message = "The monitoring_metric_writer_role must be either a predefined role (roles/*) or a custom role (projects/*/roles/*)."
623623
}
624624
}
625+
626+
variable "enterprise_config" {
627+
description = "(Optional) Enable or disable GKE enterprise. Valid values are DEFAULT and ENTERPRISE."
628+
type = string
629+
default = null
630+
}

modules/beta-autopilot-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Then perform the following commands on the root folder:
9393
| enable\_secret\_manager\_addon | Enable the Secret Manager add-on for this cluster | `bool` | `false` | no |
9494
| enable\_tpu | Enable Cloud TPU resources in the cluster. WARNING: changing this after cluster creation is destructive! | `bool` | `false` | no |
9595
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | `bool` | `true` | no |
96+
| enterprise\_config | (Optional) Enable or disable GKE enterprise. Valid values are DEFAULT and ENTERPRISE. | `string` | `null` | no |
9697
| filestore\_csi\_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | `bool` | `false` | no |
9798
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers. Either flag `add_master_webhook_firewall_rules` or `add_cluster_firewall_rules` (also adds egress rules) must be set to `true` for inbound-ports firewall rules to be applied. | `list(string)` | <pre>[<br> "8443",<br> "9443",<br> "15017"<br>]</pre> | no |
9899
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |

0 commit comments

Comments
 (0)