Skip to content

Commit

Permalink
PR for issue-216 add support for flex shape (#217)
Browse files Browse the repository at this point in the history
* issue-216 support for flex shape and issue-219

Signed-off-by: Karthic Ravindran <[email protected]>

* changes in terraform.tfvars.example

Signed-off-by: Karthic Ravindran <[email protected]>
  • Loading branch information
karthicgit authored Sep 10, 2020
1 parent 1832f41 commit e2ef377
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
29 changes: 21 additions & 8 deletions docs/terraformoptions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -456,22 +456,35 @@ admission_controller_options = {
|v1.16.8

|`node_pools`
|The number, shape and quantities per subnets of node pools to create. Each key and tuple pair corresponds to 1 node pool. The first parameter in the tuple sets the shape of the worker node, the 2nd parameter sets the size of the node pool and the 3rd parameter the boot volume size in GB. An empty value ("") for the boot volume size will default the boot volume size to 50GB. A minimum of 1 worker worker nodes per node pool will be created. Refer to {uri-topology}[topology] for more thorough examples.
a|The number, shape of node pools and node_pool_size to create. Each key and tuple pair corresponds to 1 node pool.

* shape defines the worker node shape to use for each pool
* ocpus defines the number of OCPUs that will be used if VM.Standard.E3.Flex shape is used
* node_pool_size defines the number of worker nodes in each nodepool
* boot_volume_size defines the custom boot volume size in GBs for the worker nodes.

If an empty nodepool like np3 = {} is specified, then a nodepool will default values:

* shape=VM.Standard.E3.Flex
* ocpus=1
* node_pool_size=1
* boot_volume_size=50

Refer to {uri-topology}[topology] for more thorough examples.
|e.g.
[source]
node_pools = {
np1 = ["VM.Standard.E2.2", 1, 50]
np2 = ["VM.Standard2.8", 2, 100]
np3 = ["VM.Standard.E2.2", 1, 200]
np4 = ["VM.Standard.E2.2", 1, ""]
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,node_pool_size=2,boot_volume_size=150}
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150}
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
}

|
[source]
node_pools = {
np1 = ["VM.Standard.E2.2", 1, 50]
np2 = ["VM.Standard2.8", 2, 100]
np3 = ["VM.Standard.E2.2", 1, 200]
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,node_pool_size=2,boot_volume_size=150}
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150}
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
}

|`node_pools_to_drain`
Expand Down
2 changes: 1 addition & 1 deletion modules/oke/datasources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data "oci_core_images" "latest_images" {
compartment_id = var.compartment_id
operating_system = var.node_pools.node_pool_os
operating_system_version = var.node_pools.node_pool_os_version
shape = element(each.value, 0)
shape = lookup(each.value,"shape","VM.Standard.E3.Flex")
sort_by = "TIMECREATED"
}

Expand Down
13 changes: 9 additions & 4 deletions modules/oke/nodepools.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ resource "oci_containerengine_node_pool" "nodepools" {
}
}
# set quantity to a minimum of 1 to allow small clusters.
size = max(1, element(each.value,1))
size = max(1, lookup(each.value,"node_pool_size",1))
}
dynamic "node_shape_config" {
for_each = length(regexall("Flex",lookup(each.value,"shape","VM.Standard.E3.Flex"))) > 0 ? [1] : []
content {
ocpus = max(1,lookup(each.value,"ocpus",1))
}
}

node_source_details {
boot_volume_size_in_gbs = element(each.value,2) == "" ? 50 : element(each.value,2)
boot_volume_size_in_gbs = lookup(each.value,"boot_volume_size",50)
image_id = var.node_pools.node_pool_image_id == "none" ? data.oci_core_images.latest_images[each.key].images[0].id : var.node_pools.node_pool_image_id
source_type = "IMAGE"
}

node_shape = element(each.value,0)
node_shape = lookup(each.value,"shape","VM.Standard.E3.Flex")

ssh_public_key = file(var.oke_ssh_keys.ssh_public_key_path)

Expand Down
7 changes: 3 additions & 4 deletions terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,9 @@ dashboard_enabled = false
kubernetes_version = "v1.16.8"

node_pools = {
np1 = ["VM.Standard.E2.2", 1, 50]
np2 = ["VM.Standard2.8", 2, 100]
np3 = ["VM.Standard.E2.2", 1, 200]
# np4 = ["VM.Standard.E2.2", 4, 500]
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,node_pool_size=2,boot_volume_size=150}
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150}
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
}

node_pools_to_drain = [ "np1", "np2", "np3" ]
Expand Down
9 changes: 5 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ variable "kubernetes_version" {

variable "node_pools" {
default = {
np1 = ["VM.Standard.E2.2", 1, 50]
np2 = ["VM.Standard2.8", 2, 100]
np3 = ["VM.Standard.E2.2", 1, 200]
np1 = {shape="VM.Standard.E3.Flex",ocpus=2,node_pool_size=2,boot_volume_size=150}
np2 = {shape="VM.Standard.E2.2",node_pool_size=2,boot_volume_size=150}
np3 = {shape="VM.Standard.E2.2",node_pool_size=1}
}
description = "Tuple of node pools. Each key maps to a node pool. Each value is a tuple of shape (string) and size(number)."
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)"
type = map(any)
}

Expand Down Expand Up @@ -408,6 +408,7 @@ variable "ocir_urls" {
uk-london-1 = "lhr.ocir.io"
us-ashburn-1 = "iad.ocir.io"
us-phoenix-1 = "phx.ocir.io"
us-sanjose-1 = "sjc.ocir.io"
}
type = map(string)
}
Expand Down

0 comments on commit e2ef377

Please sign in to comment.