Skip to content

Commit f7a2638

Browse files
feat: The worker_pools input variable now requires a value for the operating_system option to be passed to it (#516)
1 parent a98352d commit f7a2638

File tree

11 files changed

+98
-8
lines changed

11 files changed

+98
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ module "ocp_base" {
111111
pool_name = "default"
112112
machine_type = "bx2.4x16"
113113
workers_per_zone = 2
114+
operating_system = "REDHAT_8_64"
114115
}
115116
]
116117
}
@@ -323,7 +324,7 @@ Optionally, you need the following permissions to attach Access Management tags
323324
| <a name="input_verify_worker_network_readiness"></a> [verify\_worker\_network\_readiness](#input\_verify\_worker\_network\_readiness) | By setting this to true, a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false. | `bool` | `true` | no |
324325
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | Id of the VPC instance where this cluster will be provisioned | `string` | n/a | yes |
325326
| <a name="input_vpc_subnets"></a> [vpc\_subnets](#input\_vpc\_subnets) | Metadata that describes the VPC's subnets. Obtain this information from the VPC where this cluster will be created | <pre>map(list(object({<br/> id = string<br/> zone = string<br/> cidr_block = string<br/> })))</pre> | n/a | yes |
326-
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | List of worker pools | <pre>list(object({<br/> subnet_prefix = optional(string)<br/> vpc_subnets = optional(list(object({<br/> id = string<br/> zone = string<br/> cidr_block = string<br/> })))<br/> pool_name = string<br/> machine_type = string<br/> workers_per_zone = number<br/> resource_group_id = optional(string)<br/> operating_system = optional(string)<br/> labels = optional(map(string))<br/> minSize = optional(number)<br/> secondary_storage = optional(string)<br/> maxSize = optional(number)<br/> enableAutoscaling = optional(bool)<br/> boot_volume_encryption_kms_config = optional(object({<br/> crk = string<br/> kms_instance_id = string<br/> kms_account_id = optional(string)<br/> }))<br/> additional_security_group_ids = optional(list(string))<br/> }))</pre> | n/a | yes |
327+
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | List of worker pools | <pre>list(object({<br/> subnet_prefix = optional(string)<br/> vpc_subnets = optional(list(object({<br/> id = string<br/> zone = string<br/> cidr_block = string<br/> })))<br/> pool_name = string<br/> machine_type = string<br/> workers_per_zone = number<br/> resource_group_id = optional(string)<br/> operating_system = string<br/> labels = optional(map(string))<br/> minSize = optional(number)<br/> secondary_storage = optional(string)<br/> maxSize = optional(number)<br/> enableAutoscaling = optional(bool)<br/> boot_volume_encryption_kms_config = optional(object({<br/> crk = string<br/> kms_instance_id = string<br/> kms_account_id = optional(string)<br/> }))<br/> additional_security_group_ids = optional(list(string))<br/> }))</pre> | n/a | yes |
327328
| <a name="input_worker_pools_taints"></a> [worker\_pools\_taints](#input\_worker\_pools\_taints) | Optional, Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | `null` | no |
328329
329330
### Outputs

examples/add_rules_to_sg/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ locals {
158158
pool_name = "default" # ibm_container_vpc_cluster automatically names standard pool "standard" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
159159
machine_type = "bx2.4x16"
160160
workers_per_zone = 2
161+
operating_system = "REDHAT_8_64"
161162
labels = {}
162163
resource_group_id = module.resource_group.resource_group_id
163164
}

examples/advanced/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ locals {
111111
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
112112
machine_type = "mx2.4x32"
113113
workers_per_zone = 1
114+
operating_system = "REDHAT_8_64"
114115
enableAutoscaling = true
115116
minSize = 1
116117
maxSize = 6
@@ -122,13 +123,15 @@ locals {
122123
machine_type = "bx2.4x16"
123124
workers_per_zone = 1
124125
secondary_storage = "300gb.5iops-tier"
126+
operating_system = "REDHAT_8_64"
125127
boot_volume_encryption_kms_config = local.boot_volume_encryption_kms_config
126128
},
127129
{
128130
subnet_prefix = "zone-3"
129131
pool_name = "zone-3"
130132
machine_type = "bx2.4x16"
131133
workers_per_zone = 1
134+
operating_system = "REDHAT_8_64"
132135
boot_volume_encryption_kms_config = local.boot_volume_encryption_kms_config
133136
}
134137
]

examples/basic/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ locals {
6363
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
6464
machine_type = "bx2.4x16"
6565
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
66+
operating_system = "REDHAT_8_64"
6667
}
6768
]
6869
}

examples/cross_kms_support/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ locals {
6868
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
6969
machine_type = "bx2.4x16"
7070
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
71+
operating_system = "REDHAT_8_64"
7172
boot_volume_encryption_kms_config = local.boot_volume_encryption_kms_config
7273
}
7374
]

examples/custom_sg/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ locals {
6363
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
6464
machine_type = "bx2.4x16"
6565
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
66+
operating_system = "REDHAT_8_64"
6667
},
6768
{
6869
subnet_prefix = "default"
6970
pool_name = "custom-sg"
7071
machine_type = "bx2.4x16"
7172
workers_per_zone = 2
73+
operating_system = "REDHAT_8_64"
7274
additional_security_group_ids = [module.custom_sg["custom-worker-pool-sg"].security_group_id]
7375
},
7476
]

examples/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ locals {
222222
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
223223
machine_type = "bx2.4x16"
224224
workers_per_zone = 2
225+
operating_system = "RHCOS"
225226
labels = {}
226227
resource_group_id = module.resource_group.resource_group_id
227228
boot_volume_encryption_kms_config = {

main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ locals {
5656
ocp_version_num = regex("^([0-9]+\\.[0-9]+)", local.ocp_version)[0]
5757
is_valid_version = local.ocp_version_num != null ? tonumber(local.ocp_version_num) >= 4.15 : false
5858
rhcos_allowed_ocp_version = var.operating_system == local.os_rhcos && local.is_valid_version
59-
worker_pool_rhcos_entry = [for worker in var.worker_pools : (worker.operating_system == null || worker.operating_system == local.os_rhel || (worker.operating_system == local.os_rhcos && local.is_valid_version) ? true : false)]
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)]
6060

6161
# To verify rhcos operating system exists only for OCP versions >=4.15
6262
# tflint-ignore: terraform_unused_declarations
@@ -66,8 +66,9 @@ locals {
6666
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")
6767

6868
# 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 == null || local.default_pool.operating_system == local.os_rhcos
70-
rhel_check_for_all_standalone_pools = [for pool in var.worker_pools : pool.pool_name != "default" && pool.operating_system == local.os_rhel ? true : false]
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"]
71+
7172
# tflint-ignore: terraform_unused_declarations
7273
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.")
7374

modules/fscloud/README.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,86 @@ This is a profile for IBM Cloud Red Hat OpenShift cluster on VPC Gen2 that meets
77
It has been scanned by [IBM Code Risk Analyzer (CRA)](https://cloud.ibm.com/docs/code-risk-analyzer-cli-plugin?topic=code-risk-analyzer-cli-plugin-cra-cli-plugin#terraform-command) and meets all applicable goals.
88

99

10+
### Usage
11+
12+
```hcl
13+
module "ocp_base_fscloud" {
14+
source = "terraform-ibm-modules/terraform-ibm-base-ocp-vpc/ibm//modules/fscloud"
15+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
16+
cluster_name = "example-fs-cluster-name"
17+
resource_group_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX"
18+
region = "us-south"
19+
force_delete_storage = true
20+
vpc_id = "79cxxxx-xxxx-xxxx-xxxx-xxxxxXX8667"
21+
# obtain the below values from the targeted VPC and adjust to the number of zones, subnets, subnet name, cidr_block, id, zone
22+
vpc_subnets = {
23+
zone-1 = [
24+
{
25+
cidr_block = "192.168.32.0/22"
26+
id = "0717-afc29fbb-0dbe-493a-a5b9-f3c5899cb8b9"
27+
zone = "us-south-1"
28+
},
29+
{
30+
cidr_block = "192.168.36.0/22"
31+
id = "0727-d65c1eda-9e38-4200-8452-cb8ff5bb3140"
32+
zone = "us-south-2"
33+
},
34+
{
35+
cidr_block = "192.168.40.0/22"
36+
id = "0737-9a823cd3-16bf-4ba4-a429-9e1fc7db74b8"
37+
zone = "us-south-3"
38+
}
39+
]
40+
zone-2 = [
41+
{
42+
cidr_block = "192.168.0.0/22"
43+
id = "0717-846b9490-34ae-4a6c-8288-28112dca1ba3"
44+
zone = "us-south-1"
45+
},
46+
{
47+
cidr_block = "192.168.4.0/22"
48+
id = "0727-ef8db7f6-ffa5-4d8b-a317-4631741a45ee"
49+
zone = "us-south-2"
50+
},
51+
{
52+
cidr_block = "192.168.8.0/22"
53+
id = "0737-c9a6d871-d95b-4914-abf5-82c22f4161d1"
54+
zone = "us-south-3"
55+
}
56+
]
57+
zone-3 = [
58+
{
59+
cidr_block = "192.168.16.0/22"
60+
id = "0717-d46e227c-89d4-4b02-9008-d03907a275b6"
61+
zone = "us-south-1"
62+
},
63+
{
64+
cidr_block = "192.168.20.0/22"
65+
id = "0727-93b1edcb-966c-4517-a7af-6ac63cd93adf"
66+
zone = "us-south-2"
67+
},
68+
{
69+
cidr_block = "192.168.24.0/22"
70+
id = "0737-807ec4f1-4d84-484e-b2f4-62dd5e431065"
71+
zone = "us-south-3"
72+
}
73+
]
74+
}
75+
worker_pools = [
76+
{
77+
subnet_prefix = "default"
78+
pool_name = "default"
79+
machine_type = "bx2.4x16"
80+
workers_per_zone = 2
81+
operating_system = "REDHAT_8_64"
82+
}
83+
]
84+
import_default_worker_pool_on_create = false
85+
use_private_endpoint = true
86+
87+
}
88+
```
89+
1090
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1191
### Requirements
1292

@@ -60,7 +140,7 @@ No resources.
60140
| <a name="input_verify_worker_network_readiness"></a> [verify\_worker\_network\_readiness](#input\_verify\_worker\_network\_readiness) | By setting this to true, a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false. | `bool` | `true` | no |
61141
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC instance where this cluster will be provisioned | `string` | n/a | yes |
62142
| <a name="input_vpc_subnets"></a> [vpc\_subnets](#input\_vpc\_subnets) | Metadata that describes the VPC's subnets. Obtain this information from the VPC where this cluster will be created | <pre>map(list(object({<br/> id = string<br/> zone = string<br/> cidr_block = string<br/> })))</pre> | n/a | yes |
63-
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | List of worker pools | <pre>list(object({<br/> subnet_prefix = optional(string)<br/> vpc_subnets = optional(list(object({<br/> id = string<br/> zone = string<br/> cidr_block = string<br/> })))<br/> pool_name = string<br/> machine_type = string<br/> workers_per_zone = number<br/> resource_group_id = optional(string)<br/> operating_system = optional(string)<br/> labels = optional(map(string))<br/> minSize = optional(number)<br/> secondary_storage = optional(string)<br/> maxSize = optional(number)<br/> enableAutoscaling = optional(bool)<br/> boot_volume_encryption_kms_config = optional(object({<br/> crk = string<br/> kms_instance_id = string<br/> kms_account_id = optional(string)<br/> }))<br/> additional_security_group_ids = optional(list(string))<br/> }))</pre> | n/a | yes |
143+
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | List of worker pools | <pre>list(object({<br/> subnet_prefix = optional(string)<br/> vpc_subnets = optional(list(object({<br/> id = string<br/> zone = string<br/> cidr_block = string<br/> })))<br/> pool_name = string<br/> machine_type = string<br/> workers_per_zone = number<br/> resource_group_id = optional(string)<br/> operating_system = string<br/> labels = optional(map(string))<br/> minSize = optional(number)<br/> secondary_storage = optional(string)<br/> maxSize = optional(number)<br/> enableAutoscaling = optional(bool)<br/> boot_volume_encryption_kms_config = optional(object({<br/> crk = string<br/> kms_instance_id = string<br/> kms_account_id = optional(string)<br/> }))<br/> additional_security_group_ids = optional(list(string))<br/> }))</pre> | n/a | yes |
64144
| <a name="input_worker_pools_taints"></a> [worker\_pools\_taints](#input\_worker\_pools\_taints) | Optional, Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | `null` | no |
65145

66146
### Outputs

modules/fscloud/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ variable "worker_pools" {
6666
machine_type = string
6767
workers_per_zone = number
6868
resource_group_id = optional(string)
69-
operating_system = optional(string)
69+
operating_system = string
7070
labels = optional(map(string))
7171
minSize = optional(number)
7272
secondary_storage = optional(string)

0 commit comments

Comments
 (0)