Skip to content

Commit 23b5243

Browse files
kudipudibharathkkb
andauthored
feat: Added support for specifying min_cpu_platform in node config - … (#1057)
* feat: Added support for specifying min_cpu_platform in node config - fix #985 * README: Added description for min_cpu_platform in node config Co-authored-by: Bharath KKB <[email protected]>
1 parent dd410d7 commit 23b5243

File tree

16 files changed

+62
-34
lines changed

16 files changed

+62
-34
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ The node_pools variable takes the following parameters:
241241
| key | The key required for the taint | | Required |
242242
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |
243243
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
244+
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
244245
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
245246
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
246247
| name | The name of the node pool | | Required |

autogen/main/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ The node_pools variable takes the following parameters:
194194
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
195195
{% endif %}
196196
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
197+
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
197198
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
198199
{% if beta_cluster %}
199200
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |

autogen/main/cluster.tf.tmpl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,12 @@ resource "google_container_cluster" "primary" {
261261

262262
node_config {
263263
{% if beta_cluster %}
264-
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
264+
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
265265
{% else %}
266-
image_type = lookup(var.node_pools[0], "image_type", "COS")
266+
image_type = lookup(var.node_pools[0], "image_type", "COS")
267267
{% endif %}
268-
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
268+
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
269+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
269270

270271
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
271272

@@ -385,6 +386,7 @@ locals {
385386
"accelerator_type",
386387
"local_ssd_count",
387388
"machine_type",
389+
"min_cpu_platform",
388390
"preemptible",
389391
"service_account",
390392
]
@@ -528,11 +530,12 @@ resource "google_container_node_pool" "pools" {
528530

529531
node_config {
530532
{% if beta_cluster %}
531-
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
533+
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
532534
{% else %}
533-
image_type = lookup(each.value, "image_type", "COS")
535+
image_type = lookup(each.value, "image_type", "COS")
534536
{% endif %}
535-
machine_type = lookup(each.value, "machine_type", "e2-medium")
537+
machine_type = lookup(each.value, "machine_type", "e2-medium")
538+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
536539
labels = merge(
537540
lookup(lookup(local.node_pools_labels, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
538541
lookup(lookup(local.node_pools_labels, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},

cluster.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ resource "google_container_cluster" "primary" {
138138
initial_node_count = var.initial_node_count
139139

140140
node_config {
141-
image_type = lookup(var.node_pools[0], "image_type", "COS")
142-
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
141+
image_type = lookup(var.node_pools[0], "image_type", "COS")
142+
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
143+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
143144

144145
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
145146

@@ -252,8 +253,9 @@ resource "google_container_node_pool" "pools" {
252253

253254

254255
node_config {
255-
image_type = lookup(each.value, "image_type", "COS")
256-
machine_type = lookup(each.value, "machine_type", "e2-medium")
256+
image_type = lookup(each.value, "image_type", "COS")
257+
machine_type = lookup(each.value, "machine_type", "e2-medium")
258+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
257259
labels = merge(
258260
lookup(lookup(local.node_pools_labels, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
259261
lookup(lookup(local.node_pools_labels, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},

modules/beta-private-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ The node_pools variable takes the following parameters:
314314
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |
315315
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
316316
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
317+
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
317318
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
318319
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
319320
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. | 1 | Optional |

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ resource "google_container_cluster" "primary" {
231231
initial_node_count = var.initial_node_count
232232

233233
node_config {
234-
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
235-
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
234+
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
235+
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
236+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
236237

237238
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
238239

@@ -343,6 +344,7 @@ locals {
343344
"accelerator_type",
344345
"local_ssd_count",
345346
"machine_type",
347+
"min_cpu_platform",
346348
"preemptible",
347349
"service_account",
348350
]
@@ -472,8 +474,9 @@ resource "google_container_node_pool" "pools" {
472474
}
473475

474476
node_config {
475-
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
476-
machine_type = lookup(each.value, "machine_type", "e2-medium")
477+
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
478+
machine_type = lookup(each.value, "machine_type", "e2-medium")
479+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
477480
labels = merge(
478481
lookup(lookup(local.node_pools_labels, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
479482
lookup(lookup(local.node_pools_labels, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ The node_pools variable takes the following parameters:
292292
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |
293293
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
294294
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
295+
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
295296
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
296297
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
297298
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. | 1 | Optional |

modules/beta-private-cluster/cluster.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ resource "google_container_cluster" "primary" {
231231
initial_node_count = var.initial_node_count
232232

233233
node_config {
234-
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
235-
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
234+
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
235+
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
236+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
236237

237238
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
238239

@@ -388,8 +389,9 @@ resource "google_container_node_pool" "pools" {
388389
}
389390

390391
node_config {
391-
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
392-
machine_type = lookup(each.value, "machine_type", "e2-medium")
392+
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
393+
machine_type = lookup(each.value, "machine_type", "e2-medium")
394+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
393395
labels = merge(
394396
lookup(lookup(local.node_pools_labels, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
395397
lookup(lookup(local.node_pools_labels, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},

modules/beta-public-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ The node_pools variable takes the following parameters:
301301
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |
302302
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
303303
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
304+
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
304305
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
305306
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
306307
| max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. | 1 | Optional |

modules/beta-public-cluster-update-variant/cluster.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ resource "google_container_cluster" "primary" {
231231
initial_node_count = var.initial_node_count
232232

233233
node_config {
234-
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
235-
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
234+
image_type = lookup(var.node_pools[0], "image_type", lookup(var.node_pools[0], "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
235+
machine_type = lookup(var.node_pools[0], "machine_type", "e2-medium")
236+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
236237

237238
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
238239

@@ -324,6 +325,7 @@ locals {
324325
"accelerator_type",
325326
"local_ssd_count",
326327
"machine_type",
328+
"min_cpu_platform",
327329
"preemptible",
328330
"service_account",
329331
]
@@ -453,8 +455,9 @@ resource "google_container_node_pool" "pools" {
453455
}
454456

455457
node_config {
456-
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
457-
machine_type = lookup(each.value, "machine_type", "e2-medium")
458+
image_type = lookup(each.value, "image_type", lookup(each.value, "sandbox_enabled", var.sandbox_enabled) ? "COS_CONTAINERD" : "COS")
459+
machine_type = lookup(each.value, "machine_type", "e2-medium")
460+
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
458461
labels = merge(
459462
lookup(lookup(local.node_pools_labels, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
460463
lookup(lookup(local.node_pools_labels, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},

0 commit comments

Comments
 (0)