Skip to content

Commit 464c056

Browse files
authored
Initial node labels addition (#284)
* Initial node labels Signed-off-by: Karthic Ravindran <[email protected]> * two labels added in examples Signed-off-by: Karthic Ravindran <[email protected]>
1 parent 6362054 commit 464c056

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

docs/terraformoptions.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ a|The number, shape of node pools and node_pool_size to create. Each key and tup
565565
* memory defines the amount of memory in GBs that will be used if VM.Standard.E3.Flex shape is used
566566
* node_pool_size defines the number of worker nodes in each nodepool
567567
* boot_volume_size defines the custom boot volume size in GBs for the worker nodes.
568+
* label defines the initial node labels to use for the nodepool
568569

569570
If an empty nodepool like np3 = {} is specified, then a nodepool will have the following default values:
570571

@@ -579,15 +580,15 @@ Refer to {uri-topology}[topology] for more thorough examples.
579580
[source]
580581
node_pools = {
581582
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,memory=20,node_pool_size=2,boot_volume_size=150}
582-
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150}
583+
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150,label={app="application",name="test"}}
583584
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
584585
}
585586

586587
|
587588
[source]
588589
node_pools = {
589590
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,node_pool_size=2,boot_volume_size=150}
590-
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150}
591+
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150,label={app="application",name="test"}}
591592
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
592593
}
593594

modules/oke/nodepools.tf

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ resource "oci_containerengine_node_pool" "nodepools" {
3232
}
3333
node_source_details {
3434
boot_volume_size_in_gbs = lookup(each.value, "boot_volume_size", 50)
35-
image_id = var.node_pools.node_pool_image_id == "none" ? local.node_pool_image_id : var.node_pools.node_pool_image_id
36-
source_type = data.oci_containerengine_node_pool_option.node_pool_options.sources[0].source_type
35+
image_id = var.node_pools.node_pool_image_id == "none" ? local.node_pool_image_id : var.node_pools.node_pool_image_id
36+
source_type = data.oci_containerengine_node_pool_option.node_pool_options.sources[0].source_type
3737
}
3838

3939
node_shape = lookup(each.value, "shape", "VM.Standard.E3.Flex")
@@ -44,8 +44,11 @@ resource "oci_containerengine_node_pool" "nodepools" {
4444
lifecycle {
4545
ignore_changes = [kubernetes_version, node_source_details[0].image_id]
4646
}
47-
# initial_node_labels {
48-
# key = "key"
49-
# value = "value"
50-
# }
47+
dynamic "initial_node_labels" {
48+
for_each = lookup(each.value, "label", "") != "" ? each.value.label : {}
49+
content {
50+
key = initial_node_labels.key
51+
value = initial_node_labels.value
52+
}
53+
}
5154
}

modules/oke/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ variable "oke_cluster" {
6262

6363
variable "node_pools" {
6464
type = object({
65-
node_pools = map(any)
65+
node_pools = any
6666
node_pool_name_prefix = string
6767
node_pool_image_id = string
6868
node_pool_os = string

terraform.tfvars.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ kubernetes_version = "v1.19.7"
206206

207207
node_pools = {
208208
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,memory=20,node_pool_size=2,boot_volume_size=150}
209-
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150}
209+
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150,label={app="application",name="test"}}
210210
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
211211
}
212212

variables.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ variable "node_pools" {
359359
np3 = { shape = "VM.Standard.E2.2", node_pool_size = 1 }
360360
}
361361
description = "Tuple of node pools. Each key maps to a node pool. Each value is a tuple of shape (string),ocpus(number) , node_pool_size(number) and boot_volume_size(number)"
362-
type = map(any)
362+
type = any
363363
}
364364

365365
variable "node_pools_to_drain" {
@@ -402,6 +402,10 @@ variable "node_pool_os_version" {
402402
default = "7.9"
403403
description = "The version of image Operating System to use."
404404
type = string
405+
validation {
406+
condition = (var.node_pool_os_version >= 7.9)
407+
error_message = "Node_pool_os_version should be equal or greater than 7.9."
408+
}
405409
}
406410

407411
variable "pods_cidr" {

0 commit comments

Comments
 (0)