Skip to content

Commit ffe6524

Browse files
authored
Added option to specify ADs in node pools (#520)
Added option to specify ADs in node pools. If not specified, the default remains to deploy to all ADs of region. Fixes: #515 Signed-off-by: Andrea Stacchiotti <[email protected]>
1 parent f24e96a commit ffe6524

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

docs/terraformoptions.adoc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,14 +739,9 @@ Refer to {uri-topology}[topology] for more thorough examples.
739739
node_pools = {
740740
np1 = { shape = "VM.Standard.E4.Flex", ocpus = 1, memory = 16, node_pool_size = 1, boot_volume_size = 150, label = { app = "frontend", pool = "np1" } }
741741
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150,label={app="application",name="test"}}
742-
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
743-
}
744-
|
745-
node_pools = {
746-
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,node_pool_size=2,boot_volume_size=150}
747-
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150,label={app="application",name="test"}}
748-
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
749-
}
742+
np3 = {shape="VM.Standard.E2.2",node_pool_size=1,placement_ads=[1]}
743+
}
744+
|{}
750745

751746
|node_pool_image_id
752747
|The OCID of custom image to use when provisioning worker nodes. When no OCID is specified, the worker nodes will use the node_pool_os and node_pool_os_version to identify an image to provision the worker nodes.

modules/oke/locals.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ locals {
66
# used by cluster
77
lb_subnet = var.preferred_load_balancer == "public" ? "pub_lb" : "int_lb"
88

9-
ad_names = [
10-
for ad_name in data.oci_identity_availability_domains.ad_list.availability_domains :
11-
ad_name.name
12-
]
9+
ad_number_to_name = {
10+
for ad in data.oci_identity_availability_domains.ad_list.availability_domains :
11+
parseint(substr(ad.name, -1, -1), 10) => ad.name
12+
}
13+
ad_numbers = keys(local.ad_number_to_name)
1314

1415
# dynamic group all oke clusters in a compartment
1516
dynamic_group_rule_all_clusters = "ALL {resource.type = 'cluster', resource.compartment.id = '${var.compartment_id}'}"

modules/oke/nodepools.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ resource "oci_containerengine_node_pool" "nodepools" {
2121
# iterating over ADs
2222
dynamic "placement_configs" {
2323
iterator = ad_iterator
24-
for_each = local.ad_names
24+
for_each = [for n in lookup(each.value, "placement_ads", local.ad_numbers):
25+
local.ad_number_to_name[n]]
2526
content {
2627
availability_domain = ad_iterator.value
2728
subnet_id = var.cluster_subnets["workers"]

terraform.tfvars.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ node_pools = {
182182
np1 = { shape = "VM.Standard.E4.Flex", ocpus = 1, memory = 16, node_pool_size = 1, boot_volume_size = 150, label = { app = "frontend", pool = "np1" } }
183183
np2 = { shape = "VM.Standard.E4.Flex", ocpus = 1, memory = 16, node_pool_size = 1, boot_volume_size = 150, label = { app = "frontend", pool = "np2" } }
184184
# np3 = { shape = "VM.Standard.E4.Flex", ocpus = 1, memory = 16, node_pool_size = 1, boot_volume_size = 150, label = { app = "frontend", pool = "np1" } }
185-
# np4 = { shape = "VM.Standard.E4.Flex", ocpus = 1, memory = 16, node_pool_size = 1, boot_volume_size = 150, label = { app = "frontend", pool = "np1" } }
185+
# np4 = { shape = "VM.Standard.E4.Flex", ocpus = 1, memory = 16, node_pool_size = 1, placement_ads = [1] }
186186
# np2 = {shape="VM.Standard.E4.Flex",ocpus=4,memory=16,node_pool_size=1,boot_volume_size=150, label={app="backend",pool="np2"}}
187187
# np3 = {shape="VM.Standard.A1.Flex",ocpus=8,memory=16,node_pool_size=1,boot_volume_size=150, label={pool="np3"}}
188188
# np4 = {shape="BM.Standard2.52",node_pool_size=1,boot_volume_size=150}

0 commit comments

Comments
 (0)