Skip to content

Commit

Permalink
feat: removed the operating_system input variable. To manage the op…
Browse files Browse the repository at this point in the history
…erating system value, use the `operating_system` option in the `worker_pools` input (#545)
  • Loading branch information
Aashiq-J authored Oct 18, 2024
1 parent d37ea00 commit fbb1924
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 31 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ Optionally, you need the following permissions to attach Access Management tags
| <a name="input_number_of_lbs"></a> [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 |
| <a name="input_ocp_entitlement"></a> [ocp\_entitlement](#input\_ocp\_entitlement) | Value that is applied to the entitlements for OCP cluster provisioning | `string` | `null` | no |
| <a name="input_ocp_version"></a> [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 |
| <a name="input_operating_system"></a> [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 |
| <a name="input_pod_subnet_cidr"></a> [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 |
| <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where the cluster will be provisioned. | `string` | n/a | yes |
| <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 |
Expand Down
2 changes: 0 additions & 2 deletions examples/multiple_mzr_clusters/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.")
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion modules/fscloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ No resources.
| <a name="input_number_of_lbs"></a> [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 |
| <a name="input_ocp_entitlement"></a> [ocp\_entitlement](#input\_ocp\_entitlement) | Value that is applied to the entitlements for OCP cluster provisioning | `string` | `null` | no |
| <a name="input_ocp_version"></a> [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 |
| <a name="input_operating_system"></a> [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 |
| <a name="input_pod_subnet_cidr"></a> [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 |
| <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where the cluster will be provisioned. | `string` | n/a | yes |
| <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 |
Expand Down
1 change: 0 additions & 1 deletion modules/fscloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 0 additions & 11 deletions modules/fscloud/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

}

##############################################################################
10 changes: 0 additions & 10 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fbb1924

Please sign in to comment.