Skip to content

Commit 83cb0ea

Browse files
robo-caphyder
authored andcommitted
Add node-cycle-mode support
1 parent 203376f commit 83cb0ea

File tree

10 files changed

+29
-7
lines changed

10 files changed

+29
-7
lines changed

docs/src/guide/workers_node_cycle.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ When you set `node_cycling_enabled` to `true` for a node pool, OKE will compare
1818

1919
The `node_cycling_max_surge` (default: `1`) and `node_cycling_max_unavailable` (default: `0`) node_pool attributes can be configured with absolute values or percentage values, calculated relative to the node_pool `size`. These attributes determine how OKE will replace the nodes with a stale config in the node_pool.
2020

21+
The `node_cycling_mode` attribute supports two node cycling modes:
22+
- `instance` - (default) - cycling deletes and recreates a new node with the changes applied.
23+
- `boot_volume` cycling swaps the boot volume on the same node.
24+
25+
**Notes:**
26+
- Only a subset of fields (`kubernetes_version`, `image_id`, `boot_volume_size`, `node_metadata`, `ssh_public_key`, `volume_kms_key_id`) can be changed with `boot_volume` cycling.
27+
- The cycling operation will attempt to bring all nodes in the NodePool in sync with the NodePool specification. If `boot_volume` cycling mode is chosen, and the node needs changes to fields that can not be updated via a `boot_volume` cycle, the cycle attempt for that node will fail. The cycle_mode has to be changed to `instance` and the node-cycle operation needs to be retried.
28+
2129
When cycling nodes, the OKE cordons, drains, and terminates nodes according to the node pool's cordon and drain options.
2230

2331
**Notes:**

examples/workers/vars-workers-node-cycling.auto.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ worker_pools = {
1010
node_cycling_enabled = true
1111
node_cycling_max_surge = "25%"
1212
node_cycling_max_unavailable = 0
13+
node_cycling_mode = ["instance"] # An alternative value is boot_volume. Only a single mode is supported.
1314
}
1415
}

modules/cluster-addons/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ terraform {
77
required_providers {
88
oci = {
99
source = "oracle/oci"
10-
version = ">= 6.17.0"
10+
version = ">= 6.37.0"
1111
}
1212
}
1313
}

modules/cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ terraform {
77
required_providers {
88
oci = {
99
source = "oracle/oci"
10-
version = ">= 6.32.0"
10+
version = ">= 6.37.0"
1111
}
1212
}
1313
}

modules/iam/group-cluster.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ locals {
1414
cluster_policy_statements = coalesce(var.cluster_kms_key_id, "none") != "none" ? tolist([format(
1515
"Allow dynamic-group %v to use keys in compartment id %v where target.key.id = '%v'",
1616
local.cluster_group_name, var.compartment_id, var.cluster_kms_key_id,
17-
)]) : []
17+
), format("Allow dynamic-group %v to read instance-images in compartment id %v",
18+
local.cluster_group_name, var.compartment_id)
19+
]) : []
1820
}
1921

2022
resource "oci_identity_dynamic_group" "cluster" {

modules/iam/policy.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ resource "oci_identity_policy" "cluster" {
3434
resource "oci_identity_policy" "cluster_ipv6" {
3535
provider = oci.home
3636
count = var.enable_ipv6 && var.create_iam_resources ? 1 : 0
37-
compartment_id = var.network_compartment_id
37+
compartment_id = var.network_compartment_id != null ? var.network_compartment_id : var.compartment_id
3838
description = format("Policies for OKE Terraform state %v", var.state_id)
3939
name = var.policy_name
40-
statements = [format("Allow any-user to use ipv6s in compartment %s where all { request.principal.id = '%s' }", var.network_compartment_id, var.cluster_id )]
40+
statements = [format("Allow any-user to use ipv6s in compartment %s where all { request.principal.type = 'cluster' }", var.network_compartment_id != null ? var.network_compartment_id : var.compartment_id )]
4141
defined_tags = local.defined_tags
4242
freeform_tags = local.freeform_tags
4343
lifecycle {

modules/workers/locals.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ locals {
4646
node_cycling_enabled = false
4747
node_cycling_max_surge = 1
4848
node_cycling_max_unavailable = 0
49+
node_cycling_mode = ["instance"]
4950
node_labels = var.node_labels
5051
nsg_ids = [] # empty pool-specific default
5152
ocpus = local.ocpus
@@ -169,8 +170,17 @@ locals {
169170
pool.autoscale ? { "oke.oraclecloud.com/cluster_autoscaler" = "managed" } : {},
170171
pool.node_labels,
171172
)
173+
174+
# Override Node-cycling mode
175+
node_cycling_mode = pool.node_cycling_mode != null ? [ for entry in pool.node_cycling_mode: lookup(local.supported_node_cycling_mode, lower(entry)) ] : null
176+
172177
}) if tobool(pool.create)
173178
}
179+
180+
supported_node_cycling_mode = {
181+
instance = "INSTANCE_REPLACE"
182+
boot_volume = "BOOT_VOLUME_REPLACE"
183+
}
174184

175185
enabled_modes = distinct([for w in values(local.enabled_worker_pools) : w.mode])
176186

modules/workers/nodepools.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ resource "oci_containerengine_node_pool" "autoscaled_workers" {
261261
is_node_cycling_enabled = each.value.node_cycling_enabled
262262
maximum_surge = each.value.node_cycling_max_surge
263263
maximum_unavailable = each.value.node_cycling_max_unavailable
264+
cycle_modes = each.value.node_cycling_mode
264265
}
265266

266267
node_source_details {

modules/workers/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ terraform {
1212

1313
oci = {
1414
source = "oracle/oci"
15-
version = ">= 4.119.0"
15+
version = ">= 6.37.0"
1616
}
1717
}
1818
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ terraform {
2323
oci = {
2424
configuration_aliases = [oci.home]
2525
source = "oracle/oci"
26-
version = ">= 4.119.0"
26+
version = ">= 6.37.0"
2727
}
2828

2929
random = {

0 commit comments

Comments
 (0)