Skip to content

Commit 7cc0626

Browse files
DrFaust92apeabody
andauthored
feat: support reservation affinity (#2010)
Signed-off-by: drfaust92 <ilia.lazebnik@gmail.com> Co-authored-by: Andrew Peabody <andrewpeabody@google.com>
1 parent 8e53122 commit 7cc0626

File tree

16 files changed

+96
-30
lines changed

16 files changed

+96
-30
lines changed

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ The node_pools variable takes the following parameters:
358358
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | | Optional |
359359
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | | Optional |
360360
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | | Optional |
361+
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | | Optional |
362+
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | | Optional |
363+
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | | Optional |
361364

362365
## windows_node_pools variable
363366
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.

Diff for: autogen/main/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ The node_pools variable takes the following parameters:
261261
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | | Optional |
262262
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | | Optional |
263263
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | | Optional |
264+
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | | Optional |
265+
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | | Optional |
266+
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | | Optional |
264267

265268
## windows_node_pools variable
266269
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.

Diff for: autogen/main/cluster.tf.tmpl

+7-2
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ locals {
718718
"boot_disk_kms_key",
719719
"queued_provisioning",
720720
"enable_confidential_storage",
721+
"consume_reservation_type",
722+
"reservation_affinity_key",
723+
"reservation_affinity_values"
721724
]
722725
}
723726

@@ -896,9 +899,11 @@ resource "google_container_node_pool" "windows_pools" {
896899
}
897900
}
898901
dynamic "reservation_affinity" {
899-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
902+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
900903
content {
901-
consume_reservation_type = "NO_RESERVATION"
904+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
905+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
906+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
902907
}
903908
}
904909
labels = merge(

Diff for: cluster.tf

+8-4
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,11 @@ resource "google_container_node_pool" "pools" {
605605
}
606606
}
607607
dynamic "reservation_affinity" {
608-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
608+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
609609
content {
610-
consume_reservation_type = "NO_RESERVATION"
610+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
611+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
612+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
611613
}
612614
}
613615
labels = merge(
@@ -885,9 +887,11 @@ resource "google_container_node_pool" "windows_pools" {
885887
}
886888
}
887889
dynamic "reservation_affinity" {
888-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
890+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
889891
content {
890-
consume_reservation_type = "NO_RESERVATION"
892+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
893+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
894+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
891895
}
892896
}
893897
labels = merge(

Diff for: modules/beta-private-cluster-update-variant/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ The node_pools variable takes the following parameters:
417417
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | | Optional |
418418
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | | Optional |
419419
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | | Optional |
420+
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | | Optional |
421+
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | | Optional |
422+
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | | Optional |
420423

421424
## windows_node_pools variable
422425
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.

Diff for: modules/beta-private-cluster-update-variant/cluster.tf

+11-4
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,9 @@ locals {
614614
"boot_disk_kms_key",
615615
"queued_provisioning",
616616
"enable_confidential_storage",
617+
"consume_reservation_type",
618+
"reservation_affinity_key",
619+
"reservation_affinity_values"
617620
]
618621
}
619622

@@ -769,9 +772,11 @@ resource "google_container_node_pool" "pools" {
769772
}
770773
}
771774
dynamic "reservation_affinity" {
772-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
775+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
773776
content {
774-
consume_reservation_type = "NO_RESERVATION"
777+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
778+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
779+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
775780
}
776781
}
777782
labels = merge(
@@ -1063,9 +1068,11 @@ resource "google_container_node_pool" "windows_pools" {
10631068
}
10641069
}
10651070
dynamic "reservation_affinity" {
1066-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
1071+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
10671072
content {
1068-
consume_reservation_type = "NO_RESERVATION"
1073+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
1074+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
1075+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
10691076
}
10701077
}
10711078
labels = merge(

Diff for: modules/beta-private-cluster/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ The node_pools variable takes the following parameters:
395395
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | | Optional |
396396
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | | Optional |
397397
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | | Optional |
398+
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | | Optional |
399+
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | | Optional |
400+
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | | Optional |
398401

399402
## windows_node_pools variable
400403
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.

Diff for: modules/beta-private-cluster/cluster.tf

+8-4
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,11 @@ resource "google_container_node_pool" "pools" {
690690
}
691691
}
692692
dynamic "reservation_affinity" {
693-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
693+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
694694
content {
695-
consume_reservation_type = "NO_RESERVATION"
695+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
696+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
697+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
696698
}
697699
}
698700
labels = merge(
@@ -983,9 +985,11 @@ resource "google_container_node_pool" "windows_pools" {
983985
}
984986
}
985987
dynamic "reservation_affinity" {
986-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
988+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
987989
content {
988-
consume_reservation_type = "NO_RESERVATION"
990+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
991+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
992+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
989993
}
990994
}
991995
labels = merge(

Diff for: modules/beta-public-cluster-update-variant/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ The node_pools variable takes the following parameters:
404404
| queued_provisioning | Makes nodes obtainable through the ProvisioningRequest API exclusively. | | Optional |
405405
| gpu_sharing_strategy | The type of GPU sharing strategy to enable on the GPU node. Accepted values are: "TIME_SHARING" and "MPS". | | Optional |
406406
| max_shared_clients_per_gpu | The maximum number of containers that can share a GPU. | | Optional |
407+
| consume_reservation_type | The type of reservation consumption. Accepted values are: "UNSPECIFIED": Default value (should not be specified). "NO_RESERVATION": Do not consume from any reserved capacity, "ANY_RESERVATION": Consume any reservation available, "SPECIFIC_RESERVATION": Must consume from a specific reservation. Must specify key value fields for specifying the reservations. | | Optional |
408+
| reservation_affinity_key | The label key of a reservation resource. To target a SPECIFIC_RESERVATION by name, specify "compute.googleapis.com/reservation-name" as the key and specify the name of your reservation as its value. | | Optional |
409+
| reservation_affinity_values | The list of label values of reservation resources. For example: the name of the specific reservation when using a key of "compute.googleapis.com/reservation-name". This should be passed as comma separated string. | | Optional |
407410

408411
## windows_node_pools variable
409412
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.

Diff for: modules/beta-public-cluster-update-variant/cluster.tf

+11-4
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ locals {
593593
"boot_disk_kms_key",
594594
"queued_provisioning",
595595
"enable_confidential_storage",
596+
"consume_reservation_type",
597+
"reservation_affinity_key",
598+
"reservation_affinity_values"
596599
]
597600
}
598601

@@ -748,9 +751,11 @@ resource "google_container_node_pool" "pools" {
748751
}
749752
}
750753
dynamic "reservation_affinity" {
751-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
754+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
752755
content {
753-
consume_reservation_type = "NO_RESERVATION"
756+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
757+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
758+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
754759
}
755760
}
756761
labels = merge(
@@ -1042,9 +1047,11 @@ resource "google_container_node_pool" "windows_pools" {
10421047
}
10431048
}
10441049
dynamic "reservation_affinity" {
1045-
for_each = lookup(each.value, "queued_provisioning", false) ? [true] : []
1050+
for_each = lookup(each.value, "queued_provisioning", false) || lookup(each.value, "consume_reservation_type", "") != "" ? [each.value] : []
10461051
content {
1047-
consume_reservation_type = "NO_RESERVATION"
1052+
consume_reservation_type = lookup(reservation_affinity.value, "queued_provisioning", false) ? "NO_RESERVATION" : lookup(reservation_affinity.value, "consume_reservation_type", null)
1053+
key = lookup(reservation_affinity.value, "reservation_affinity_key", null)
1054+
values = lookup(reservation_affinity.value, "reservation_affinity_values", null) == null ? null : [for s in split(",", lookup(reservation_affinity.value, "reservation_affinity_values", null)) : trimspace(s)]
10481055
}
10491056
}
10501057
labels = merge(

0 commit comments

Comments
 (0)