Skip to content

Commit c1f831e

Browse files
authored
fix: removed default value for worker_pools ivariable (#97)
BREAKING CHANGE: var.worker_pools is now a required variable with no default value
1 parent 92a7be0 commit c1f831e

File tree

11 files changed

+100
-147
lines changed

11 files changed

+100
-147
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ No modules.
171171
| <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 |
172172
| <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 |
173173
| <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 |
174-
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | List of worker pools | <pre>list(object({<br> subnet_prefix = string<br> pool_name = string<br> machine_type = string<br> workers_per_zone = number<br> resource_group_id = optional(string)<br> labels = optional(map(string))<br> boot_volume_encryption_kms_config = optional(object({<br> crk = string<br> kms_instance_id = string<br> kms_account_id = optional(string)<br> }))<br> }))</pre> | <pre>[<br> {<br> "machine_type": "bx2.4x16",<br> "pool_name": "default",<br> "subnet_prefix": "zone-1",<br> "workers_per_zone": 2<br> },<br> {<br> "machine_type": "bx2.4x16",<br> "pool_name": "zone-2",<br> "subnet_prefix": "zone-2",<br> "workers_per_zone": 2<br> },<br> {<br> "machine_type": "bx2.4x16",<br> "pool_name": "zone-3",<br> "subnet_prefix": "zone-3",<br> "workers_per_zone": 2<br> }<br>]</pre> | no |
174+
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | List of worker pools | <pre>list(object({<br> subnet_prefix = string<br> pool_name = string<br> machine_type = string<br> workers_per_zone = number<br> resource_group_id = optional(string)<br> labels = optional(map(string))<br> boot_volume_encryption_kms_config = optional(object({<br> crk = string<br> kms_instance_id = string<br> kms_account_id = optional(string)<br> }))<br> }))</pre> | n/a | yes |
175175
| <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 |
176176

177177
## Outputs

examples/apply_taints/main.tf

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module "resource_group" {
1414
###############################################################################
1515

1616
module "vpc" {
17-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v4.2.0"
17+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v5.0.1"
1818
resource_group_id = module.resource_group.resource_group_id
1919
region = var.region
2020
prefix = var.prefix
@@ -41,26 +41,6 @@ module "kp_all_inclusive" {
4141
##############################################################################
4242
# Base OCP Cluster
4343
##############################################################################
44-
locals {
45-
cluster_vpc_subnets = {
46-
zone-1 = [{
47-
id = module.vpc.subnet_zone_list[0].id
48-
zone = module.vpc.subnet_zone_list[0].zone
49-
cidr_block = module.vpc.subnet_zone_list[0].cidr
50-
}],
51-
zone-2 = [{
52-
id = module.vpc.subnet_zone_list[1].id
53-
zone = module.vpc.subnet_zone_list[1].zone
54-
cidr_block = module.vpc.subnet_zone_list[1].cidr
55-
}],
56-
zone-3 = [{
57-
id = module.vpc.subnet_zone_list[2].id
58-
zone = module.vpc.subnet_zone_list[2].zone
59-
cidr_block = module.vpc.subnet_zone_list[2].cidr
60-
}]
61-
}
62-
}
63-
6444
module "ocp_base" {
6545
source = "../.."
6646
cluster_name = var.prefix
@@ -69,7 +49,7 @@ module "ocp_base" {
6949
region = var.region
7050
force_delete_storage = true
7151
vpc_id = module.vpc.vpc_id
72-
vpc_subnets = local.cluster_vpc_subnets
52+
vpc_subnets = module.vpc.subnet_detail_map
7353
worker_pools = var.worker_pools
7454
worker_pools_taints = var.worker_pools_taints
7555
ocp_version = var.ocp_version

examples/existing_cos/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module "ocp_base" {
1313
force_delete_storage = true
1414
vpc_id = var.vpc_id
1515
vpc_subnets = var.vpc_subnets
16+
worker_pools = var.worker_pools
1617
use_existing_cos = true
1718
existing_cos_id = var.existing_cos_id
1819
}

examples/existing_cos/variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,21 @@ variable "existing_cos_id" {
6161
description = "The ID of an existing COS instance to use for cluster provisioning"
6262
}
6363

64+
variable "worker_pools" {
65+
type = list(object({
66+
subnet_prefix = string
67+
pool_name = string
68+
machine_type = string
69+
workers_per_zone = number
70+
resource_group_id = optional(string)
71+
labels = optional(map(string))
72+
boot_volume_encryption_kms_config = optional(object({
73+
crk = string
74+
kms_instance_id = string
75+
kms_account_id = optional(string)
76+
}))
77+
}))
78+
description = "List of worker pools."
79+
}
80+
6481
##############################################################################

examples/multiple_mzr_clusters/main.tf

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module "resource_group" {
1414
###############################################################################
1515

1616
module "vpc" {
17-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v4.2.0"
17+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v5.0.1"
1818
resource_group_id = module.resource_group.resource_group_id
1919
region = var.region
2020
prefix = var.prefix
@@ -30,26 +30,28 @@ module "vpc" {
3030
###############################################################################
3131

3232
locals {
33-
cluster_vpc_subnets = {
34-
zone-1 = [{
35-
id = module.vpc.subnet_zone_list[0].id
36-
zone = module.vpc.subnet_zone_list[0].zone
37-
cidr_block = module.vpc.subnet_zone_list[0].cidr
33+
cluster_1_vpc_subnets = {
34+
default = [
35+
for subnet in module.vpc.subnet_detail_map :
36+
{
37+
id = subnet[0].id
38+
zone = subnet[0].zone
39+
cidr_block = subnet[0].cidr_block
3840
}
39-
],
40-
zone-2 = [{
41-
id = module.vpc.subnet_zone_list[1].id
42-
zone = module.vpc.subnet_zone_list[1].zone
43-
cidr_block = module.vpc.subnet_zone_list[1].cidr
44-
}
45-
],
46-
zone-3 = [{
47-
id = module.vpc.subnet_zone_list[2].id
48-
zone = module.vpc.subnet_zone_list[2].zone
49-
cidr_block = module.vpc.subnet_zone_list[2].cidr
41+
]
42+
}
43+
44+
cluster_2_vpc_subnets = {
45+
default = [
46+
for subnet in module.vpc.subnet_detail_map :
47+
{
48+
id = subnet[1].id
49+
zone = subnet[1].zone
50+
cidr_block = subnet[1].cidr_block
5051
}
5152
]
5253
}
54+
5355
}
5456

5557
module "ocp_base_cluster_1" {
@@ -59,7 +61,7 @@ module "ocp_base_cluster_1" {
5961
region = var.region
6062
force_delete_storage = true
6163
vpc_id = module.vpc.vpc_id
62-
vpc_subnets = local.cluster_vpc_subnets
64+
vpc_subnets = local.cluster_1_vpc_subnets
6365
worker_pools = var.worker_pools
6466
worker_pools_taints = var.worker_pools_taints
6567
ocp_version = var.ocp_version
@@ -74,7 +76,7 @@ module "ocp_base_cluster_2" {
7476
region = var.region
7577
force_delete_storage = true
7678
vpc_id = module.vpc.vpc_id
77-
vpc_subnets = local.cluster_vpc_subnets
79+
vpc_subnets = local.cluster_2_vpc_subnets
7880
worker_pools = var.worker_pools
7981
worker_pools_taints = var.worker_pools_taints
8082
ocp_version = var.ocp_version

examples/multiple_mzr_clusters/variables.tf

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ variable "addresses" {
7474
zone-3 = optional(list(string))
7575
})
7676
default = {
77-
zone-1 = ["10.10.10.0/24"]
78-
zone-2 = ["10.20.10.0/24"]
79-
zone-3 = ["10.30.10.0/24"]
77+
zone-1 = ["10.243.0.0/23", "10.243.5.0/24"]
78+
zone-2 = ["10.243.64.0/23", "10.243.69.0/24"]
79+
zone-3 = ["10.243.128.0/23", "10.243.133.0/24"]
8080
}
8181
}
8282

@@ -107,22 +107,37 @@ variable "subnets" {
107107
zone-1 = [
108108
{
109109
acl_name = "vpc-acl"
110-
name = "zone-1"
111-
cidr = "10.10.10.0/24"
110+
name = "z1-subnet-a"
111+
cidr = "10.243.0.0/23"
112+
},
113+
{
114+
acl_name = "vpc-acl"
115+
name = "z1-subnet-b"
116+
cidr = "10.243.5.0/24"
112117
}
113118
],
114119
zone-2 = [
115120
{
116121
acl_name = "vpc-acl"
117-
name = "zone-2"
118-
cidr = "10.20.10.0/24"
122+
name = "z2-subnet-c"
123+
cidr = "10.243.64.0/23"
124+
},
125+
{
126+
acl_name = "vpc-acl"
127+
name = "z2-subnet-d"
128+
cidr = "10.243.69.0/24"
119129
}
120130
],
121131
zone-3 = [
122132
{
123133
acl_name = "vpc-acl"
124-
name = "zone-3"
125-
cidr = "10.30.10.0/24"
134+
name = "z3-subnet-e"
135+
cidr = "10.243.128.0/23"
136+
},
137+
{
138+
acl_name = "vpc-acl"
139+
name = "z3-subnet-f"
140+
cidr = "10.243.133.0/24"
126141
}
127142
]
128143
}
@@ -144,17 +159,17 @@ variable "worker_pools" {
144159
}))
145160
default = [
146161
{
147-
subnet_prefix = "zone-1"
162+
subnet_prefix = "default"
148163
pool_name = "default" # ibm_container_vpc_cluster automatically names standard pool "standard" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
149164
machine_type = "bx2.4x16"
150165
workers_per_zone = 2
151166
},
152167
{
153-
subnet_prefix = "zone-2"
154-
pool_name = "zone-2"
168+
subnet_prefix = "default"
169+
pool_name = "logging-worker-pool"
155170
machine_type = "bx2.4x16"
156171
workers_per_zone = 2
157-
labels = { "dedicated" : "zone-2" }
172+
labels = { "dedicated" : "logging-worker-pool" }
158173
}
159174
]
160175
description = "List of worker pools"
@@ -166,9 +181,9 @@ variable "worker_pools_taints" {
166181

167182
default = {
168183
all = []
169-
zone-2 = [{
184+
logging-worker-pool = [{
170185
key = "dedicated"
171-
value = "zone-2"
186+
value = "logging-worker-pool"
172187
effect = "NoExecute"
173188
}]
174189
default = []

examples/single_zone_cluster/main.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module "resource_group" {
1414
###############################################################################
1515

1616
module "vpc" {
17-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v4.2.0"
17+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v5.0.1"
1818
resource_group_id = module.resource_group.resource_group_id
1919
region = var.region
2020
prefix = var.prefix
@@ -31,15 +31,11 @@ module "vpc" {
3131
locals {
3232

3333
cluster_vpc_subnets = {
34-
zone-1 = [{
35-
id = module.vpc.subnet_zone_list[0].id
36-
zone = module.vpc.subnet_zone_list[0].zone
37-
cidr_block = module.vpc.subnet_zone_list[0].cidr
38-
}]
34+
default = module.vpc.subnet_detail_map.zone-1
3935
}
4036
sz_pool = [
4137
{
42-
subnet_prefix = "zone-1"
38+
subnet_prefix = "default"
4339
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
4440
machine_type = "bx2.4x16"
4541
workers_per_zone = 2

examples/standard/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Standard Example With User Managed Boot Volume Encryption
22

3-
- The example will provision an OCP cluster with one extra worker pool inside a VPC.
3+
- The example will provision an OCP cluster with the default worker pool deployed across 3 availability zones.
44
- The example also enables a key protect provider for the cluster and boot volume encryption, as well as the required COS instance.

examples/standard/main.tf

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module "resource_group" {
1414
###############################################################################
1515

1616
module "vpc" {
17-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v4.2.0"
17+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v5.0.1"
1818
resource_group_id = module.resource_group.resource_group_id
1919
region = var.region
2020
prefix = var.prefix
@@ -47,26 +47,19 @@ module "kp_all_inclusive" {
4747
##############################################################################
4848
locals {
4949
cluster_vpc_subnets = {
50-
zone-1 = [{
51-
id = module.vpc.subnet_zone_list[0].id
52-
zone = module.vpc.subnet_zone_list[0].zone
53-
cidr_block = module.vpc.subnet_zone_list[0].cidr
54-
}],
55-
zone-2 = [{
56-
id = module.vpc.subnet_zone_list[1].id
57-
zone = module.vpc.subnet_zone_list[1].zone
58-
cidr_block = module.vpc.subnet_zone_list[1].cidr
59-
}],
60-
zone-3 = [{
61-
id = module.vpc.subnet_zone_list[2].id
62-
zone = module.vpc.subnet_zone_list[2].zone
63-
cidr_block = module.vpc.subnet_zone_list[2].cidr
64-
}]
50+
default = [
51+
for subnet in module.vpc.subnet_zone_list :
52+
{
53+
id = subnet.id
54+
zone = subnet.zone
55+
cidr_block = subnet.cidr
56+
}
57+
]
6558
}
6659

6760
worker_pools = [
6861
{
69-
subnet_prefix = "zone-1"
62+
subnet_prefix = "default"
7063
pool_name = "default" # ibm_container_vpc_cluster automatically names standard pool "standard" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
7164
machine_type = "bx2.4x16"
7265
workers_per_zone = 2
@@ -76,18 +69,6 @@ locals {
7669
crk = module.kp_all_inclusive.keys["ocp.${var.prefix}-default-pool-boot-volume-encryption-key"].key_id
7770
kms_instance_id = module.kp_all_inclusive.key_protect_guid
7871
}
79-
},
80-
{
81-
subnet_prefix = "zone-2"
82-
pool_name = "zone-2"
83-
machine_type = "bx2.4x16"
84-
workers_per_zone = 2
85-
labels = {}
86-
resource_group_id = module.resource_group.resource_group_id
87-
boot_volume_encryption_kms_config = {
88-
crk = module.kp_all_inclusive.keys["ocp.${var.prefix}-other-pool-boot-volume-encryption-key"].key_id
89-
kms_instance_id = module.kp_all_inclusive.key_protect_guid
90-
}
9172
}
9273
]
9374
}

0 commit comments

Comments
 (0)