Skip to content

Commit b2cc2c8

Browse files
authored
feat: added the ability to skip the worker network readiness check using the verify_worker_network_readiness variable (#68)
1 parent 69de277 commit b2cc2c8

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ No modules.
168168
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The Id of an existing IBM Cloud resource group where the cluster will be grouped. | `string` | n/a | yes |
169169
| <a name="input_tags"></a> [tags](#input\_tags) | Metadata labels describing this cluster deployment, i.e. test | `list(string)` | `[]` | no |
170170
| <a name="input_use_existing_cos"></a> [use\_existing\_cos](#input\_use\_existing\_cos) | Flag indicating whether or not to use an existing COS instance | `bool` | `false` | no |
171+
| <a name="input_verify_worker_network_readiness"></a> [verify\_worker\_network\_readiness](#input\_verify\_worker\_network\_readiness) | By setting this to true, a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false. | `bool` | `true` | no |
171172
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | Id of the VPC instance where this cluster will be provisioned | `string` | n/a | yes |
172173
| <a name="input_vpc_subnets"></a> [vpc\_subnets](#input\_vpc\_subnets) | Metadata that describes the VPC's subnets. Obtain this information from the VPC where this cluster will be created | <pre>map(list(object({<br> id = string<br> zone = string<br> cidr_block = string<br> })))</pre> | n/a | yes |
173174
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | List of worker pools | <pre>list(object({<br> subnet_prefix = string<br> pool_name = string<br> machine_type = string<br> workers_per_zone = number<br> resource_group_id = optional(string)<br> labels = optional(map(string))<br> }))</pre> | <pre>[<br> {<br> "machine_type": "bx2.4x16",<br> "pool_name": "default",<br> "subnet_prefix": "zone-1",<br> "workers_per_zone": 2<br> },<br> {<br> "machine_type": "bx2.4x16",<br> "pool_name": "zone-2",<br> "subnet_prefix": "zone-2",<br> "workers_per_zone": 2<br> },<br> {<br> "machine_type": "bx2.4x16",<br> "pool_name": "zone-3",<br> "subnet_prefix": "zone-3",<br> "workers_per_zone": 2<br> }<br>]</pre> | no |

main.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ resource "ibm_container_vpc_worker_pool" "pool" {
223223
# Apply taints to worker pools i.e. other_pools
224224

225225
dynamic "taints" {
226-
for_each = var.worker_pools_taints == null ? [] : concat(var.worker_pools_taints["all"], var.worker_pools_taints[each.value["pool_name"]])
226+
for_each = var.worker_pools_taints == null ? [] : concat(var.worker_pools_taints["all"], lookup(var.worker_pools_taints, each.value["pool_name"], []))
227227
content {
228228
effect = taints.value.effect
229229
key = taints.value.key
@@ -265,7 +265,7 @@ resource "ibm_container_vpc_worker_pool" "autoscaling_pool" {
265265
# Apply taints to worker pools i.e. other_pools
266266

267267
dynamic "taints" {
268-
for_each = var.worker_pools_taints == null ? [] : concat(var.worker_pools_taints["all"], var.worker_pools_taints[each.value["pool_name"]])
268+
for_each = var.worker_pools_taints == null ? [] : concat(var.worker_pools_taints["all"], lookup(var.worker_pools_taints, each.value["pool_name"], []))
269269
content {
270270
effect = taints.value.effect
271271
key = taints.value.key
@@ -277,6 +277,10 @@ resource "ibm_container_vpc_worker_pool" "autoscaling_pool" {
277277

278278
##############################################################################
279279
# Confirm network healthy by ensuring master can communicate with all workers.
280+
#
281+
# Please note:
282+
# The network health check is applicable only if the cluster is accessible.
283+
#
280284
# To do this, we run a script to execute "kubectl logs" against each calico
281285
# daemonset pod (as there will be one pod per node) and ensure it passes.
282286
#
@@ -290,10 +294,13 @@ resource "ibm_container_vpc_worker_pool" "autoscaling_pool" {
290294
# push down an updated vpn config, and then the vpn server and client need
291295
# to pick up this updated config. Depending on how busy the network
292296
# microservice is handling requests, there might be a delay.
297+
293298
##############################################################################
294299

295300
resource "null_resource" "confirm_network_healthy" {
296301

302+
count = var.verify_worker_network_readiness ? 1 : 0
303+
297304
depends_on = [ibm_container_vpc_worker_pool.pool, ibm_container_vpc_worker_pool.autoscaling_pool]
298305

299306
provisioner "local-exec" {

module-metadata.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@
201201
"line": 141
202202
}
203203
},
204+
"verify_worker_network_readiness": {
205+
"name": "verify_worker_network_readiness",
206+
"type": "bool",
207+
"description": "By setting this to true, a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false.",
208+
"default": true,
209+
"source": [
210+
"null_resource.confirm_network_healthy.count"
211+
],
212+
"pos": {
213+
"filename": "variables.tf",
214+
"line": 169
215+
}
216+
},
204217
"vpc_id": {
205218
"name": "vpc_id",
206219
"type": "string",
@@ -482,12 +495,15 @@
482495
"mode": "managed",
483496
"type": "null_resource",
484497
"name": "confirm_network_healthy",
498+
"attributes": {
499+
"count": "verify_worker_network_readiness"
500+
},
485501
"provider": {
486502
"name": "null"
487503
},
488504
"pos": {
489505
"filename": "main.tf",
490-
"line": 295
506+
"line": 300
491507
}
492508
},
493509
"null_resource.reset_api_key": {

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,10 @@ variable "vpc_id" {
166166
description = "Id of the VPC instance where this cluster will be provisioned"
167167
}
168168

169-
#############################################################################
169+
variable "verify_worker_network_readiness" {
170+
type = bool
171+
description = "By setting this to true, a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false."
172+
default = true
173+
}
174+
175+
##############################################################################

0 commit comments

Comments
 (0)