Skip to content

Commit 6c7b454

Browse files
authored
feat: added support for the ibm-storage-operator addon (#483)
1 parent 752b4c5 commit 6c7b454

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ Optionally, you need the following permissions to attach Access Management tags
244244
| <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 |
245245
| <a name="input_additional_lb_security_group_ids"></a> [additional\_lb\_security\_group\_ids](#input\_additional\_lb\_security\_group\_ids) | Additional security groups to add to the load balancers associated with the cluster. Ensure that the number\_of\_lbs is set to the number of LBs associated with the cluster. This comes in addition to the IBM maintained security group. | `list(string)` | `[]` | no |
246246
| <a name="input_additional_vpe_security_group_ids"></a> [additional\_vpe\_security\_group\_ids](#input\_additional\_vpe\_security\_group\_ids) | Additional security groups to add to all existing load balancers. This comes in addition to the IBM maintained security group. | <pre>object({<br> master = optional(list(string), [])<br> registry = optional(list(string), [])<br> api = optional(list(string), [])<br> })</pre> | `{}` | no |
247-
| <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> debug-tool = optional(string)<br> image-key-synchronizer = optional(string)<br> openshift-data-foundation = optional(string)<br> vpc-file-csi-driver = optional(string)<br> static-route = optional(string)<br> cluster-autoscaler = optional(string)<br> vpc-block-csi-driver = optional(string)<br> })</pre> | `null` | no |
247+
| <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 and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, 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> debug-tool = optional(string)<br> image-key-synchronizer = optional(string)<br> openshift-data-foundation = optional(string)<br> vpc-file-csi-driver = optional(string)<br> static-route = optional(string)<br> cluster-autoscaler = optional(string)<br> vpc-block-csi-driver = optional(string)<br> ibm-storage-operator = optional(string)<br> })</pre> | `{}` | no |
248248
| <a name="input_attach_ibm_managed_security_group"></a> [attach\_ibm\_managed\_security\_group](#input\_attach\_ibm\_managed\_security\_group) | Specify whether to attach the IBM-defined default security group (whose name is kube-<clusterid>) to all worker nodes. Only applicable if custom\_security\_group\_ids is set. | `bool` | `true` | no |
249249
| <a name="input_cluster_config_endpoint_type"></a> [cluster\_config\_endpoint\_type](#input\_cluster\_config\_endpoint\_type) | Specify which type of endpoint to use for for cluster config access: 'default', 'private', 'vpe', 'link'. 'default' value will use the default endpoint of the cluster. | `string` | `"default"` | no |
250250
| <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 |

main.tf

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ 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-
]
32-
addons_list = var.addons != null ? { for k, v in var.addons : k => v if v != null } : {}
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
34-
3528
delete_timeout = "2h"
3629
create_timeout = "3h"
3730
update_timeout = "3h"
@@ -297,7 +290,7 @@ resource "null_resource" "reset_api_key" {
297290
##############################################################################
298291

299292
data "ibm_container_cluster_config" "cluster_config" {
300-
count = var.verify_worker_network_readiness || lookup(local.addons_list, "cluster-autoscaler", null) != null ? 1 : 0
293+
count = var.verify_worker_network_readiness || lookup(var.addons, "cluster-autoscaler", null) != null ? 1 : 0
301294
cluster_name_id = local.cluster_id
302295
config_dir = "${path.module}/kubeconfig"
303296
admin = true # workaround for https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/issues/374
@@ -443,18 +436,36 @@ resource "null_resource" "confirm_network_healthy" {
443436
}
444437
}
445438

439+
##############################################################################
440+
# Addons
441+
##############################################################################
442+
446443
# Lookup the current default csi-driver version
447444
data "ibm_container_addons" "existing_addons" {
448445
cluster = local.cluster_id
449446
}
450447

448+
locals {
449+
# for each cluster, look for installed csi driver to get version. If array is empty (no csi driver) then null is returned
450+
csi_driver_version = [
451+
for addon in data.ibm_container_addons.existing_addons.addons :
452+
addon.version if addon.name == "vpc-block-csi-driver"
453+
]
454+
455+
# get the addons and their versions and create an addons map including the corresponding csi_driver_version
456+
addons = merge(
457+
{ for addon_name, addon_version in(var.addons != null ? var.addons : {}) : addon_name => addon_version if addon_version != null },
458+
local.csi_driver_version != null ? { vpc-block-csi-driver = local.csi_driver_version[0] } : {}
459+
)
460+
}
461+
462+
451463
resource "ibm_container_addons" "addons" {
452464

453465
# Worker pool creation can start before the 'ibm_container_vpc_cluster' completes since there is no explicit
454466
# depends_on in 'ibm_container_vpc_worker_pool', just an implicit depends_on on the cluster ID. Cluster ID can exist before
455467
# 'ibm_container_vpc_cluster' completes, so hence need to add explicit depends on against 'ibm_container_vpc_cluster' here.
456-
depends_on = [ibm_container_vpc_cluster.cluster, ibm_container_vpc_cluster.autoscaling_cluster, ibm_container_vpc_worker_pool.pool, ibm_container_vpc_worker_pool.autoscaling_pool, null_resource.confirm_network_healthy]
457-
468+
depends_on = [ibm_container_vpc_cluster.cluster, ibm_container_vpc_cluster.autoscaling_cluster, ibm_container_vpc_worker_pool.pool, ibm_container_vpc_worker_pool.autoscaling_pool, null_resource.confirm_network_healthy]
458469
cluster = local.cluster_id
459470
resource_group_id = var.resource_group_id
460471

@@ -488,7 +499,7 @@ locals {
488499
}
489500

490501
resource "null_resource" "config_map_status" {
491-
count = lookup(local.addons_list, "cluster-autoscaler", null) != null ? 1 : 0
502+
count = lookup(var.addons, "cluster-autoscaler", null) != null ? 1 : 0
492503
depends_on = [ibm_container_addons.addons]
493504

494505
provisioner "local-exec" {
@@ -501,7 +512,7 @@ resource "null_resource" "config_map_status" {
501512
}
502513

503514
resource "kubernetes_config_map_v1_data" "set_autoscaling" {
504-
count = lookup(local.addons_list, "cluster-autoscaler", null) != null ? 1 : 0
515+
count = lookup(var.addons, "cluster-autoscaler", null) != null ? 1 : 0
505516
depends_on = [null_resource.config_map_status]
506517

507518
metadata {

modules/fscloud/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ No resources.
3535
| <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 |
3636
| <a name="input_additional_lb_security_group_ids"></a> [additional\_lb\_security\_group\_ids](#input\_additional\_lb\_security\_group\_ids) | Additional security groups to add to the load balancers associated with the cluster. Ensure that the number\_of\_lbs is set to the number of LBs associated with the cluster. This comes in addition to the IBM maintained security group. | `list(string)` | `[]` | no |
3737
| <a name="input_additional_vpe_security_group_ids"></a> [additional\_vpe\_security\_group\_ids](#input\_additional\_vpe\_security\_group\_ids) | Additional security groups to add to all existing load balancers. This comes in addition to the IBM maintained security group. | <pre>object({<br> master = optional(list(string), [])<br> registry = optional(list(string), [])<br> api = optional(list(string), [])<br> })</pre> | `{}` | no |
38-
| <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> debug-tool = optional(string)<br> image-key-synchronizer = optional(string)<br> openshift-data-foundation = optional(string)<br> vpc-file-csi-driver = optional(string)<br> static-route = optional(string)<br> cluster-autoscaler = optional(string)<br> vpc-block-csi-driver = optional(string)<br> })</pre> | `null` | no |
38+
| <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 and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, 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> debug-tool = optional(string)<br> image-key-synchronizer = optional(string)<br> openshift-data-foundation = optional(string)<br> vpc-file-csi-driver = optional(string)<br> static-route = optional(string)<br> cluster-autoscaler = optional(string)<br> vpc-block-csi-driver = optional(string)<br> ibm-storage-operator = optional(string)<br> })</pre> | `{}` | no |
3939
| <a name="input_attach_ibm_managed_security_group"></a> [attach\_ibm\_managed\_security\_group](#input\_attach\_ibm\_managed\_security\_group) | Specify whether to attach the IBM-defined default security group (whose name is kube-<clusterid>) to all worker nodes. Only applicable if custom\_security\_group\_ids is set. | `bool` | `true` | no |
4040
| <a name="input_cluster_config_endpoint_type"></a> [cluster\_config\_endpoint\_type](#input\_cluster\_config\_endpoint\_type) | Specify which type of endpoint to use for for cluster config access: 'private', 'vpe', 'link'. | `string` | `"private"` | no |
4141
| <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 |

modules/fscloud/variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ variable "addons" {
130130
static-route = optional(string)
131131
cluster-autoscaler = optional(string)
132132
vpc-block-csi-driver = optional(string)
133+
ibm-storage-operator = optional(string)
133134
})
134-
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"
135-
default = null
135+
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 and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, 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"
136+
default = {}
136137
}
137138

138139
variable "access_tags" {

variables.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,11 @@ variable "addons" {
292292
static-route = optional(string)
293293
cluster-autoscaler = optional(string)
294294
vpc-block-csi-driver = optional(string)
295+
ibm-storage-operator = optional(string)
295296
})
296-
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"
297-
default = null
297+
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 and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, 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"
298+
nullable = false
299+
default = {}
298300
}
299301

300302
variable "manage_all_addons" {

0 commit comments

Comments
 (0)