Skip to content

Commit cb2ee8d

Browse files
authored
feat: exposed the addons variable in the fscloud submodule + refactored the logic around csi-driver version determination (#258)
1 parent 68f6880 commit cb2ee8d

File tree

8 files changed

+61
-19
lines changed

8 files changed

+61
-19
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ Optionally, you need the following permissions to attach Access Management tags
179179
| [null_resource.confirm_network_healthy](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
180180
| [null_resource.reset_api_key](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
181181
| [time_sleep.wait_operators](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
182+
| [ibm_container_addons.existing_addons](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_addons) | data source |
182183
| [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_config) | data source |
183184
| [ibm_container_cluster_versions.cluster_versions](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_versions) | data source |
184185
@@ -187,7 +188,7 @@ Optionally, you need the following permissions to attach Access Management tags
187188
| Name | Description | Type | Default | Required |
188189
|------|-------------|------|---------|:--------:|
189190
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the resources created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
190-
| <a name="input_addons"></a> [addons](#input\_addons) | List of all addons supported by the ocp cluster. | <pre>object({<br> alb-oauth-proxy = optional(string)<br> debug-tool = optional(string)<br> image-key-synchronizer = optional(string)<br> istio = optional(string)<br> openshift-data-foundation = optional(string)<br> static-route = optional(string)<br> cluster-autoscaler = optional(string)<br> vpc-block-csi-driver = optional(string)<br> })</pre> | `null` | no |
191+
| <a name="input_addons"></a> [addons](#input\_addons) | Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions | <pre>object({<br> alb-oauth-proxy = optional(string)<br> debug-tool = optional(string)<br> image-key-synchronizer = optional(string)<br> istio = optional(string)<br> openshift-data-foundation = optional(string)<br> static-route = optional(string)<br> cluster-autoscaler = optional(string)<br> vpc-block-csi-driver = optional(string)<br> })</pre> | `null` | no |
191192
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name that will be assigned to the provisioned cluster | `string` | n/a | yes |
192193
| <a name="input_cluster_ready_when"></a> [cluster\_ready\_when](#input\_cluster\_ready\_when) | The cluster is ready when one of the following: MasterNodeReady (not recommended), OneWorkerNodeReady, Normal, IngressReady | `string` | `"IngressReady"` | no |
193194
| <a name="input_cos_name"></a> [cos\_name](#input\_cos\_name) | Name of the COS instance to provision. New instance only provisioned if `use_existing_cos = false`. Default: `<cluster_name>_cos` | `string` | `null` | no |

cra-tf-validate-ignore-rules.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
"description": "Check whether Cloud Object Storage network access is restricted to a specific IP range",
66
"ignore_reason": "This module supports restricting network access using Context Based Restrictions (CBRs), however SCC does not yet support scanning for CBR rules, hence the rule currently fails. SCC CBR support is being tracked in AHA SCC-961",
77
"is_valid": true
8+
},
9+
{
10+
"scc_rule_id": "rule-216e2449-27d7-4afc-929a-b66e196a9cf9",
11+
"description": "Check whether Flow Logs for VPC are enabled",
12+
"ignore_reason": "This rule is not relevant to the module itself, just the VPC resource is used in the example that is scanned",
13+
"is_valid": false
814
}
915
]
1016
}

main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ locals {
2525
# tflint-ignore: terraform_unused_declarations
2626
validate_check = regex("^${local.validate_msg}$", (!local.validate_condition ? local.validate_msg : ""))
2727

28+
csi_driver_version = [
29+
for addon in data.ibm_container_addons.existing_addons.addons :
30+
addon.version if addon.name == "vpc-block-csi-driver"
31+
]
2832
addons_list = var.addons != null ? { for k, v in var.addons : k => v if v != null } : {}
29-
addons = lookup(local.addons_list, "vpc-block-csi-driver", null) == null ? merge(local.addons_list, { vpc-block-csi-driver = "5.1" }) : local.addons_list
33+
addons = lookup(local.addons_list, "vpc-block-csi-driver", null) == null ? merge(local.addons_list, { vpc-block-csi-driver = local.csi_driver_version[0] }) : local.addons_list
3034

3135
delete_timeout = "2h"
3236
create_timeout = "3h"
@@ -360,6 +364,10 @@ resource "null_resource" "confirm_network_healthy" {
360364
}
361365
}
362366

367+
# Lookup the current default csi-driver version
368+
data "ibm_container_addons" "existing_addons" {
369+
cluster = local.cluster_id
370+
}
363371

364372
resource "ibm_container_addons" "addons" {
365373

module-metadata.json

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"addons": {
2727
"name": "addons",
2828
"type": "object({\n alb-oauth-proxy = optional(string)\n debug-tool = optional(string)\n image-key-synchronizer = optional(string)\n istio = optional(string)\n openshift-data-foundation = optional(string)\n static-route = optional(string)\n cluster-autoscaler = optional(string)\n vpc-block-csi-driver = optional(string)\n })",
29-
"description": "List of all addons supported by the ocp cluster.",
29+
"description": "Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions",
3030
"pos": {
3131
"filename": "variables.tf",
3232
"line": 202
@@ -444,7 +444,7 @@
444444
},
445445
"pos": {
446446
"filename": "main.tf",
447-
"line": 364
447+
"line": 372
448448
}
449449
},
450450
"ibm_container_vpc_cluster.autoscaling_cluster": {
@@ -467,7 +467,7 @@
467467
},
468468
"pos": {
469469
"filename": "main.tf",
470-
"line": 134
470+
"line": 138
471471
}
472472
},
473473
"ibm_container_vpc_cluster.cluster": {
@@ -490,7 +490,7 @@
490490
},
491491
"pos": {
492492
"filename": "main.tf",
493-
"line": 72
493+
"line": 76
494494
}
495495
},
496496
"ibm_container_vpc_worker_pool.autoscaling_pool": {
@@ -506,7 +506,7 @@
506506
},
507507
"pos": {
508508
"filename": "main.tf",
509-
"line": 285
509+
"line": 289
510510
}
511511
},
512512
"ibm_container_vpc_worker_pool.pool": {
@@ -522,7 +522,7 @@
522522
},
523523
"pos": {
524524
"filename": "main.tf",
525-
"line": 244
525+
"line": 248
526526
}
527527
},
528528
"ibm_resource_tag.cluster_access_tag": {
@@ -539,7 +539,7 @@
539539
},
540540
"pos": {
541541
"filename": "main.tf",
542-
"line": 198
542+
"line": 202
543543
}
544544
},
545545
"ibm_resource_tag.cos_access_tag": {
@@ -555,7 +555,7 @@
555555
},
556556
"pos": {
557557
"filename": "main.tf",
558-
"line": 61
558+
"line": 65
559559
}
560560
},
561561
"kubernetes_config_map_v1_data.set_autoscaling": {
@@ -570,7 +570,7 @@
570570
},
571571
"pos": {
572572
"filename": "main.tf",
573-
"line": 405
573+
"line": 413
574574
}
575575
},
576576
"null_resource.confirm_network_healthy": {
@@ -585,7 +585,7 @@
585585
},
586586
"pos": {
587587
"filename": "main.tf",
588-
"line": 345
588+
"line": 349
589589
}
590590
},
591591
"null_resource.reset_api_key": {
@@ -597,7 +597,7 @@
597597
},
598598
"pos": {
599599
"filename": "main.tf",
600-
"line": 219
600+
"line": 223
601601
}
602602
},
603603
"time_sleep.wait_operators": {
@@ -609,11 +609,23 @@
609609
},
610610
"pos": {
611611
"filename": "main.tf",
612-
"line": 387
612+
"line": 395
613613
}
614614
}
615615
},
616616
"data_resources": {
617+
"data.ibm_container_addons.existing_addons": {
618+
"mode": "data",
619+
"type": "ibm_container_addons",
620+
"name": "existing_addons",
621+
"provider": {
622+
"name": "ibm"
623+
},
624+
"pos": {
625+
"filename": "main.tf",
626+
"line": 368
627+
}
628+
},
617629
"data.ibm_container_cluster_config.cluster_config": {
618630
"mode": "data",
619631
"type": "ibm_container_cluster_config",
@@ -627,7 +639,7 @@
627639
},
628640
"pos": {
629641
"filename": "main.tf",
630-
"line": 233
642+
"line": 237
631643
}
632644
},
633645
"data.ibm_container_cluster_versions.cluster_versions": {
@@ -642,7 +654,7 @@
642654
},
643655
"pos": {
644656
"filename": "main.tf",
645-
"line": 39
657+
"line": 43
646658
}
647659
}
648660
},
@@ -904,7 +916,7 @@
904916
},
905917
"pos": {
906918
"filename": "main.tf",
907-
"line": 43
919+
"line": 47
908920
}
909921
}
910922
}

modules/fscloud/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ No resources.
2828

2929
| Name | Description | Type | Default | Required |
3030
|------|-------------|------|---------|:--------:|
31+
| <a name="input_addons"></a> [addons](#input\_addons) | Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions | <pre>object({<br> alb-oauth-proxy = optional(string)<br> debug-tool = optional(string)<br> image-key-synchronizer = optional(string)<br> istio = optional(string)<br> openshift-data-foundation = optional(string)<br> static-route = optional(string)<br> cluster-autoscaler = optional(string)<br> vpc-block-csi-driver = optional(string)<br> })</pre> | `null` | no |
3132
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name that will be assigned to the provisioned cluster | `string` | n/a | yes |
3233
| <a name="input_cluster_ready_when"></a> [cluster\_ready\_when](#input\_cluster\_ready\_when) | The cluster is ready when one of the following: MasterNodeReady (not recommended), OneWorkerNodeReady, Normal, IngressReady | `string` | `"IngressReady"` | no |
3334
| <a name="input_existing_cos_id"></a> [existing\_cos\_id](#input\_existing\_cos\_id) | The COS id of an already existing COS instance | `string` | n/a | yes |

modules/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ module "fscloud" {
2222
existing_cos_id = var.existing_cos_id
2323
tags = var.tags
2424
kms_config = var.kms_config
25+
addons = var.addons
2526
}

modules/fscloud/variables.tf

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,18 @@ variable "verify_worker_network_readiness" {
117117
default = true
118118
}
119119

120-
120+
variable "addons" {
121+
type = object({
122+
alb-oauth-proxy = optional(string)
123+
debug-tool = optional(string)
124+
image-key-synchronizer = optional(string)
125+
istio = optional(string)
126+
openshift-data-foundation = optional(string)
127+
static-route = optional(string)
128+
cluster-autoscaler = optional(string)
129+
vpc-block-csi-driver = optional(string)
130+
})
131+
description = "Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions"
132+
default = null
133+
}
121134
##############################################################################

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ variable "addons" {
210210
cluster-autoscaler = optional(string)
211211
vpc-block-csi-driver = optional(string)
212212
})
213-
description = "List of all addons supported by the ocp cluster."
213+
description = "Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions"
214214
default = null
215215
}
216216

0 commit comments

Comments
 (0)