From 9b289c1c9d53f592378ebf8c88bc56d1d18c2e00 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Fri, 18 Oct 2024 10:05:31 +0530 Subject: [PATCH 1/2] fix: remove var.operating_system variable --- README.md | 1 - main.tf | 10 +++++----- modules/fscloud/README.md | 1 - modules/fscloud/main.tf | 1 - modules/fscloud/variables.tf | 11 ----------- variables.tf | 10 ---------- 6 files changed, 5 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 5fd99018..faef0213 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,6 @@ Optionally, you need the following permissions to attach Access Management tags | [number\_of\_lbs](#input\_number\_of\_lbs) | The number of LBs to associated the additional\_lb\_security\_group\_names security group with. | `number` | `1` | no | | [ocp\_entitlement](#input\_ocp\_entitlement) | Value that is applied to the entitlements for OCP cluster provisioning | `string` | `null` | no | | [ocp\_version](#input\_ocp\_version) | The version of the OpenShift cluster that should be provisioned (format 4.x). If no value is specified, the current default version is used. You can also specify `default`. This input is used only during initial cluster provisioning and is ignored for updates. To prevent possible destructive changes, update the cluster version outside of Terraform. | `string` | `null` | no | -| [operating\_system](#input\_operating\_system) | The operating system of the workers in the default worker pool. If no value is specified, the current default version OS will be used. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available . | `string` | `null` | no | | [pod\_subnet\_cidr](#input\_pod\_subnet\_cidr) | Specify a custom subnet CIDR to provide private IP addresses for pods. The subnet must have a CIDR of at least `/23` or larger. Default value is `172.30.0.0/16` when the variable is set to `null`. | `string` | `null` | no | | [region](#input\_region) | The IBM Cloud region where the cluster will be provisioned. | `string` | n/a | yes | | [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 | diff --git a/main.tf b/main.tf index e5c7e9e9..6a68e5ea 100644 --- a/main.tf +++ b/main.tf @@ -55,12 +55,12 @@ locals { # Strip OCP VERSION and use this ocp version in logic ocp_version_num = regex("^([0-9]+\\.[0-9]+)", local.ocp_version)[0] is_valid_version = local.ocp_version_num != null ? tonumber(local.ocp_version_num) >= 4.15 : false - rhcos_allowed_ocp_version = var.operating_system == local.os_rhcos && local.is_valid_version + rhcos_allowed_ocp_version = local.default_pool.operating_system == local.os_rhcos && local.is_valid_version worker_pool_rhcos_entry = [for worker in var.worker_pools : (worker.operating_system == local.os_rhel || (worker.operating_system == local.os_rhcos && local.is_valid_version) ? true : false)] # To verify rhcos operating system exists only for OCP versions >=4.15 # tflint-ignore: terraform_unused_declarations - cluster_rhcos_validation = var.operating_system == null || var.operating_system == local.os_rhel || local.rhcos_allowed_ocp_version ? true : tobool("RHCOS requires VPC clusters created from 4.15 onwards. Upgraded clusters from 4.14 cannot use RHCOS") + cluster_rhcos_validation = local.default_pool.operating_system == local.os_rhel || local.rhcos_allowed_ocp_version ? true : tobool("RHCOS requires VPC clusters created from 4.15 onwards. Upgraded clusters from 4.14 cannot use RHCOS") # tflint-ignore: terraform_unused_declarations worker_pool_rhcos_validation = alltrue(local.worker_pool_rhcos_entry) ? true : tobool("RHCOS requires VPC clusters created from 4.15 onwards. Upgraded clusters from 4.14 cannot use RHCOS") @@ -73,7 +73,7 @@ locals { valid_rhel_worker_pools = local.check_other_os || (local.default_pool.operating_system == local.os_rhel && alltrue(local.rhel_check_for_all_standalone_pools)) == true ? true : tobool("Choosing RHEL for the default worker pool will limit all additional worker pools to RHEL.") # Validate if RHCOS is used as operating system for the cluster then the default worker pool must be created with RHCOS - rhcos_check = var.operating_system == null || var.operating_system == local.os_rhel || (var.operating_system == local.os_rhcos && local.default_pool.operating_system == local.os_rhcos) + rhcos_check = local.default_pool.operating_system == local.os_rhel || (local.default_pool.operating_system == local.os_rhcos && local.default_pool.operating_system == local.os_rhcos) # tflint-ignore: terraform_unused_declarations default_wp_validation = local.rhcos_check == true ? true : tobool("If RHCOS is used with this cluster, the default worker pool should be created with RHCOS.") } @@ -129,7 +129,7 @@ resource "ibm_container_vpc_cluster" "cluster" { secondary_storage = local.default_pool.secondary_storage pod_subnet = var.pod_subnet_cidr service_subnet = var.service_subnet_cidr - operating_system = var.operating_system + operating_system = local.default_pool.operating_system disable_public_service_endpoint = var.disable_public_endpoint worker_labels = local.default_pool.labels disable_outbound_traffic_protection = local.disable_outbound_traffic_protection @@ -196,7 +196,7 @@ resource "ibm_container_vpc_cluster" "autoscaling_cluster" { resource_group_id = var.resource_group_id wait_till = var.cluster_ready_when force_delete_storage = var.force_delete_storage - operating_system = var.operating_system + operating_system = local.default_pool.operating_system secondary_storage = local.default_pool.secondary_storage pod_subnet = var.pod_subnet_cidr service_subnet = var.service_subnet_cidr diff --git a/modules/fscloud/README.md b/modules/fscloud/README.md index 14db9a5f..0c4e7c81 100644 --- a/modules/fscloud/README.md +++ b/modules/fscloud/README.md @@ -130,7 +130,6 @@ No resources. | [number\_of\_lbs](#input\_number\_of\_lbs) | The number of LBs to associated the additional\_lb\_security\_group\_names security group with. | `number` | `1` | no | | [ocp\_entitlement](#input\_ocp\_entitlement) | Value that is applied to the entitlements for OCP cluster provisioning | `string` | `null` | no | | [ocp\_version](#input\_ocp\_version) | The version of the OpenShift cluster that should be provisioned (format 4.x). This is only used during initial cluster provisioning, but ignored for future updates. Supports passing the string 'default' (current IKS default recommended version). If no value is passed, it will default to 'default'. | `string` | `null` | no | -| [operating\_system](#input\_operating\_system) | The operating system of the workers in the default worker pool. If no value is specified, the current default version OS will be used. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available . | `string` | `null` | no | | [pod\_subnet\_cidr](#input\_pod\_subnet\_cidr) | Specify a custom subnet CIDR to provide private IP addresses for pods. The subnet must have a CIDR of at least `/23` or larger. Default value is `172.30.0.0/16` when the variable is set to `null`. | `string` | `null` | no | | [region](#input\_region) | The IBM Cloud region where the cluster will be provisioned. | `string` | n/a | yes | | [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 | diff --git a/modules/fscloud/main.tf b/modules/fscloud/main.tf index f6c1be11..b796170f 100644 --- a/modules/fscloud/main.tf +++ b/modules/fscloud/main.tf @@ -34,5 +34,4 @@ module "fscloud" { additional_lb_security_group_ids = var.additional_lb_security_group_ids number_of_lbs = var.number_of_lbs additional_vpe_security_group_ids = var.additional_vpe_security_group_ids - operating_system = var.operating_system } diff --git a/modules/fscloud/variables.tf b/modules/fscloud/variables.tf index 4cdd1060..0099127a 100644 --- a/modules/fscloud/variables.tf +++ b/modules/fscloud/variables.tf @@ -236,15 +236,4 @@ variable "additional_vpe_security_group_ids" { default = {} } -variable "operating_system" { - type = string - description = "The operating system of the workers in the default worker pool. If no value is specified, the current default version OS will be used. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available ." - default = null - validation { - error_message = "RHEL 8 (REDHAT_8_64) or Red Hat Enterprise Linux CoreOS (RHCOS) are the allowed OS values. RHCOS requires VPC clusters created from 4.15 onwards. Upgraded clusters from 4.14 cannot use RHCOS." - condition = var.operating_system == null || var.operating_system == "REDHAT_8_64" || var.operating_system == "RHCOS" - } - -} - ############################################################################## diff --git a/variables.tf b/variables.tf index 55823b57..db6be40a 100644 --- a/variables.tf +++ b/variables.tf @@ -276,16 +276,6 @@ variable "disable_outbound_traffic_protection" { default = false } -variable "operating_system" { - type = string - description = "The operating system of the workers in the default worker pool. If no value is specified, the current default version OS will be used. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available ." - default = null - validation { - error_message = "RHEL 8 (REDHAT_8_64) or Red Hat Enterprise Linux CoreOS (RHCOS) are the allowed OS values. RHCOS requires VPC clusters created from 4.15 onwards. Upgraded clusters from 4.14 cannot use RHCOS." - condition = var.operating_system == null || var.operating_system == "REDHAT_8_64" || var.operating_system == "RHCOS" - } -} - variable "pod_subnet_cidr" { type = string default = null From 11404c8110d902b6c75f77b2270f37b71afcbe97 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Fri, 18 Oct 2024 10:40:41 +0530 Subject: [PATCH 2/2] remove from example --- examples/multiple_mzr_clusters/main.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/multiple_mzr_clusters/main.tf b/examples/multiple_mzr_clusters/main.tf index f2939356..ea53a893 100644 --- a/examples/multiple_mzr_clusters/main.tf +++ b/examples/multiple_mzr_clusters/main.tf @@ -129,7 +129,6 @@ module "ocp_base_cluster_1" { vpc_subnets = local.cluster_1_vpc_subnets disable_outbound_traffic_protection = true worker_pools = local.worker_pools - operating_system = local.os_rhcos worker_pools_taints = local.worker_pool_taints ocp_version = var.ocp_version tags = var.resource_tags @@ -146,7 +145,6 @@ module "ocp_base_cluster_2" { disable_outbound_traffic_protection = true vpc_subnets = local.cluster_2_vpc_subnets worker_pools = local.worker_pools - operating_system = local.os_rhcos worker_pools_taints = local.worker_pool_taints ocp_version = var.ocp_version tags = var.resource_tags