Skip to content

Commit 4f52a84

Browse files
authored
feat: added support for RHEL9 (#592)
1 parent c603b0b commit 4f52a84

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

examples/multiple_mzr_clusters/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ locals {
6666
# Choosing RHEL for the default worker pool will limit all additional worker pools to RHEL.
6767
# If we plan to use RHCOS with the cluster, we should create the default worker pool with RHCOS.
6868

69-
os_rhcos = "RHCOS"
70-
os_rhel = "REDHAT_8_64"
69+
os_rhcos = "RHCOS"
70+
os_rhel_9 = "RHEL_9_64"
7171
cluster_1_vpc_subnets = {
7272
default = [
7373
for subnet in ibm_is_subnet.subnet_cluster_1 :
@@ -104,7 +104,7 @@ locals {
104104
machine_type = "bx2.4x16"
105105
workers_per_zone = 2
106106
labels = { "dedicated" : "logging-worker-pool" }
107-
operating_system = local.os_rhel
107+
operating_system = local.os_rhel_9
108108
}
109109
]
110110

main.tf

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,36 @@ locals {
5151
locals {
5252
os_rhel = "REDHAT_8_64"
5353
os_rhcos = "RHCOS"
54+
os_rhel9 = "RHEL_9_64"
5455

5556
# Strip OCP VERSION and use this ocp version in logic
56-
ocp_version_num = regex("^([0-9]+\\.[0-9]+)", local.ocp_version)[0]
57-
is_valid_version = local.ocp_version_num != null ? tonumber(local.ocp_version_num) >= 4.15 : false
57+
ocp_version_num = regex("^([0-9]+\\.[0-9]+)", local.ocp_version)[0]
58+
is_valid_version = local.ocp_version_num != null ? tonumber(local.ocp_version_num) >= 4.15 : false
59+
5860
rhcos_allowed_ocp_version = local.default_pool.operating_system == local.os_rhcos && local.is_valid_version
59-
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)]
61+
62+
worker_pool_rhcos_entry = [for worker in var.worker_pools : contains([local.os_rhel, local.os_rhel9], worker.operating_system) || (worker.operating_system == local.os_rhcos && local.is_valid_version) ? true : false]
63+
6064

6165
# To verify rhcos operating system exists only for OCP versions >=4.15
6266
# tflint-ignore: terraform_unused_declarations
63-
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")
67+
cluster_rhcos_validation = contains([local.os_rhel9, local.os_rhel], local.default_pool.operating_system) || local.rhcos_allowed_ocp_version ? true : tobool("RHCOS requires VPC clusters created from 4.15 onwards. Upgraded clusters from 4.14 cannot use RHCOS")
6468

6569
# tflint-ignore: terraform_unused_declarations
6670
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")
6771

6872
# Validate if default worker pool's operating system is RHEL, all pools' operating system must be RHEL
69-
check_other_os = local.default_pool.operating_system == local.os_rhcos
70-
rhel_check_for_all_standalone_pools = [for pool in var.worker_pools : pool.operating_system == local.os_rhel if pool.pool_name != "default"]
73+
74+
rhel_check_for_all_standalone_pools = [for pool in var.worker_pools : contains([local.os_rhel, local.os_rhel9], pool.operating_system) if pool.pool_name != "default"]
7175

7276
# tflint-ignore: terraform_unused_declarations
73-
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.")
77+
valid_rhel_worker_pools = local.default_pool.operating_system == local.os_rhcos || (contains([local.os_rhel, local.os_rhel9], local.default_pool.operating_system) && alltrue(local.rhel_check_for_all_standalone_pools)) ? true : tobool("Choosing RHEL for the default worker pool will limit all additional worker pools to RHEL.")
7478

7579
# Validate if RHCOS is used as operating system for the cluster then the default worker pool must be created with RHCOS
76-
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)
80+
rhcos_check = contains([local.os_rhel, local.os_rhel9], local.default_pool.operating_system) || (local.default_pool.operating_system == local.os_rhcos && local.default_pool.operating_system == local.os_rhcos)
81+
7782
# tflint-ignore: terraform_unused_declarations
78-
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.")
83+
default_wp_validation = local.rhcos_check ? true : tobool("If RHCOS is used with this cluster, the default worker pool should be created with RHCOS.")
7984
}
8085

8186
# Lookup the current default kube version

variables.tf

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,22 @@ variable "worker_pools" {
106106
condition = alltrue([
107107
for worker_pool in var.worker_pools :
108108
anytrue([
109-
worker_pool.operating_system == "REDHAT_8_64",
110-
worker_pool.operating_system == "RHCOS"
109+
worker_pool.operating_system == local.os_rhel9,
110+
worker_pool.operating_system == local.os_rhel,
111+
worker_pool.operating_system == local.os_rhcos
111112
])
112113
])
113-
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."
114+
error_message = "RHEL 9 (RHEL_9_64), 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."
115+
}
116+
117+
validation {
118+
condition = alltrue([
119+
for wp in var.worker_pools :
120+
(local.ocp_version_num == "4.14" && wp.operating_system == local.os_rhel) ||
121+
(local.ocp_version_num == "4.15" && contains([local.os_rhel, local.os_rhcos], wp.operating_system)) ||
122+
(contains(["4.16", "4.17"], local.ocp_version_num) && contains([local.os_rhel9, local.os_rhel, local.os_rhcos], wp.operating_system))
123+
])
124+
error_message = "Invalid operating system for the given OCP version. Ensure the OS is compatible with the OCP version. Supported compatible OCP version and OS are v4.14: (REDHAT_8_64); v4.15: (REDHAT_8_64, RHCOS) ; v4.16 and v4.17: (REDHAT_8_64, RHCOS, RHEL_9_64)"
114125
}
115126
}
116127

0 commit comments

Comments
 (0)