forked from terraform-ibm-modules/terraform-ibm-base-ocp-vpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
347 lines (308 loc) · 15 KB
/
variables.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
##############################################################################
# Input Variables
##############################################################################
# Resource Group Variables
variable "resource_group_id" {
type = string
description = "The Id of an existing IBM Cloud resource group where the cluster will be grouped."
}
variable "region" {
type = string
description = "The IBM Cloud region where the cluster will be provisioned."
}
variable "use_private_endpoint" {
type = bool
description = "Set this to true to force all api calls to use the IBM Cloud private endpoints."
default = false
}
# Cluster Variables
variable "tags" {
type = list(string)
description = "Metadata labels describing this cluster deployment, i.e. test"
default = []
}
variable "cluster_name" {
type = string
description = "The name that will be assigned to the provisioned cluster"
}
variable "vpc_subnets" {
type = map(list(object({
id = string
zone = string
cidr_block = string
})))
description = "Metadata that describes the VPC's subnets. Obtain this information from the VPC where this cluster will be created"
}
variable "import_default_worker_pool_on_create" {
type = bool
description = "(Advanced users) Whether to handle the default worker pool as a stand-alone ibm_container_vpc_worker_pool resource on cluster creation. Only set to false if you understand the implications of managing the default worker pool as part of the cluster resource. Set to true to import the default worker pool as a separate resource. Set to false to manage the default worker pool as part of the cluster resource."
default = true
nullable = false
}
variable "allow_default_worker_pool_replacement" {
type = bool
description = "(Advanced users) Set to true to allow the module to recreate a default worker pool. Only use in the case where you are getting an error indicating that the default worker pool cannot be replaced on apply. Once the default worker pool is handled as a stand-alone ibm_container_vpc_worker_pool, if you wish to make any change to the default worker pool which requires the re-creation of the default pool set this variable to true."
default = false
nullable = false
}
variable "worker_pools" {
type = list(object({
subnet_prefix = optional(string)
vpc_subnets = optional(list(object({
id = string
zone = string
cidr_block = string
})))
pool_name = string
machine_type = string
workers_per_zone = number
resource_group_id = optional(string)
operating_system = optional(string)
labels = optional(map(string))
minSize = optional(number)
secondary_storage = optional(string)
maxSize = optional(number)
enableAutoscaling = optional(bool)
boot_volume_encryption_kms_config = optional(object({
crk = string
kms_instance_id = string
kms_account_id = optional(string)
}))
additional_security_group_ids = optional(list(string))
}))
description = "List of worker pools"
validation {
error_message = "Please provide value for minSize and maxSize while enableAutoscaling is set to true."
condition = length(
flatten(
[
for worker in var.worker_pools :
worker if worker.enableAutoscaling == true && worker.minSize != null && worker.maxSize != null
]
)
) == length(
flatten(
[
for worker in var.worker_pools :
worker if worker.enableAutoscaling == true
]
)
)
}
validation {
condition = length([for worker_pool in var.worker_pools : worker_pool if(worker_pool.subnet_prefix == null && worker_pool.vpc_subnets == null) || (worker_pool.subnet_prefix != null && worker_pool.vpc_subnets != null)]) == 0
error_message = "Please provide exactly one of subnet_prefix or vpc_subnets. Passing neither or both is invalid."
}
validation {
condition = alltrue([
for worker_pool in var.worker_pools :
anytrue([
worker_pool.operating_system == null,
worker_pool.operating_system == "REDHAT_8_64",
worker_pool.operating_system == "RHCOS"
])
])
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."
}
}
variable "worker_pools_taints" {
type = map(list(object({ key = string, value = string, effect = string })))
description = "Optional, Map of lists containing node taints by node-pool name"
default = null
}
variable "attach_ibm_managed_security_group" {
description = "Specify whether to attach the IBM-defined default security group (whose name is kube-<clusterid>) to all worker nodes. Only applicable if custom_security_group_ids is set."
type = bool
default = true
}
variable "custom_security_group_ids" {
description = "Security groups to add to all worker nodes. This comes in addition to the IBM maintained security group if attach_ibm_managed_security_group is set to true. If this variable is set, the default VPC security group is NOT assigned to the worker nodes."
type = list(string)
default = null
validation {
condition = var.custom_security_group_ids == null ? true : length(var.custom_security_group_ids) <= 4
error_message = "Please provide at most 4 additional security groups."
}
}
variable "additional_lb_security_group_ids" {
description = "Additional security groups to add to the load balancers associated with the cluster. Ensure that the number_of_lbs is set to the number of LBs associated with the cluster. This comes in addition to the IBM maintained security group."
type = list(string)
default = []
nullable = false
validation {
condition = var.additional_lb_security_group_ids == null ? true : length(var.additional_lb_security_group_ids) <= 4
error_message = "Please provide at most 4 additional security groups."
}
}
variable "number_of_lbs" {
description = "The number of LBs to associated the additional_lb_security_group_names security group with."
type = number
default = 1
nullable = false
validation {
condition = var.number_of_lbs >= 1
error_message = "Please set the number_of_lbs to a minumum of."
}
}
variable "additional_vpe_security_group_ids" {
description = "Additional security groups to add to all existing load balancers. This comes in addition to the IBM maintained security group."
type = object({
master = optional(list(string), [])
registry = optional(list(string), [])
api = optional(list(string), [])
})
default = {}
}
variable "ignore_worker_pool_size_changes" {
type = bool
description = "Enable if using worker autoscaling. Stops Terraform managing worker count"
default = false
}
variable "ocp_version" {
type = string
description = "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."
default = null
validation {
condition = anytrue([
var.ocp_version == null,
var.ocp_version == "default",
var.ocp_version == "4.12",
var.ocp_version == "4.13",
var.ocp_version == "4.14",
var.ocp_version == "4.15",
])
error_message = "The specified ocp_version is not of the valid versions."
}
}
variable "cluster_ready_when" {
type = string
description = "The cluster is ready when one of the following: MasterNodeReady (not recommended), OneWorkerNodeReady, Normal, IngressReady"
default = "IngressReady"
validation {
condition = contains(["MasterNodeReady", "OneWorkerNodeReady", "Normal", "IngressReady"], var.cluster_ready_when)
error_message = "The input variable cluster_ready_when must one of: \"MasterNodeReady\", \"OneWorkerNodeReady\", \"Normal\" or \"IngressReady\"."
}
}
variable "disable_public_endpoint" {
type = bool
description = "Whether access to the public service endpoint is disabled when the cluster is created. Does not affect existing clusters. You can't disable a public endpoint on an existing cluster, so you can't convert a public cluster to a private cluster. To change a public endpoint to private, create another cluster with this input set to `true`."
default = false
}
variable "ocp_entitlement" {
type = string
description = "Value that is applied to the entitlements for OCP cluster provisioning"
default = null
}
variable "force_delete_storage" {
type = bool
description = "Flag indicating whether or not to delete attached storage when destroying the cluster - Default: false"
default = false
}
variable "cos_name" {
type = string
description = "Name of the COS instance to provision for OpenShift internal registry storage. New instance only provisioned if 'enable_registry_storage' is true and 'use_existing_cos' is false. Default: '<cluster_name>_cos'"
default = null
}
variable "use_existing_cos" {
type = bool
description = "Flag indicating whether or not to use an existing COS instance for OpenShift internal registry storage. Only applicable if 'enable_registry_storage' is true"
default = false
}
variable "existing_cos_id" {
type = string
description = "The COS id of an already existing COS instance to use for OpenShift internal registry storage. Only required if 'enable_registry_storage' and 'use_existing_cos' are true"
default = null
}
variable "enable_registry_storage" {
type = bool
description = "Set to `true` to enable IBM Cloud Object Storage for the Red Hat OpenShift internal image registry. Set to `false` only for new cluster deployments in an account that is allowlisted for this feature."
default = true
}
variable "kms_config" {
type = object({
crk_id = string
instance_id = string
private_endpoint = optional(bool, true) # defaults to true
account_id = optional(string) # To attach KMS instance from another account
wait_for_apply = optional(bool, true) # defaults to true so terraform will wait until the KMS is applied to the master, ready and deployed
})
description = "Use to attach a KMS instance to the cluster. If account_id is not provided, defaults to the account in use."
default = null
}
variable "access_tags" {
type = list(string)
description = "A list of access tags to apply to the resources created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
default = []
validation {
condition = alltrue([
for tag in var.access_tags : can(regex("[\\w\\-_\\.]+:[\\w\\-_\\.]+", tag)) && length(tag) <= 128
])
error_message = "Tags must match the regular expression \"[\\w\\-_\\.]+:[\\w\\-_\\.]+\", see https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#limits for more details"
}
}
variable "disable_outbound_traffic_protection" {
type = bool
description = "Whether to allow public outbound access from the cluster workers. This is only applicable for `ocp_version` 4.15"
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
description = "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`."
}
variable "service_subnet_cidr" {
type = string
default = null
description = "Specify a custom subnet CIDR to provide private IP addresses for services. The subnet must be at least `/24` or larger. Default value is `172.21.0.0/16` when the variable is set to `null`."
}
# VPC Variables
variable "vpc_id" {
type = string
description = "Id of the VPC instance where this cluster will be provisioned"
}
variable "verify_worker_network_readiness" {
type = bool
description = "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."
default = true
}
variable "addons" {
type = object({
debug-tool = optional(string)
image-key-synchronizer = optional(string)
openshift-data-foundation = optional(string)
vpc-file-csi-driver = optional(string)
static-route = optional(string)
cluster-autoscaler = optional(string)
vpc-block-csi-driver = optional(string)
ibm-storage-operator = optional(string)
})
description = "Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions"
nullable = false
default = {}
}
variable "manage_all_addons" {
type = bool
default = false
nullable = false # null values are set to default value
description = "Instructs Terraform to manage all cluster addons, even if addons were installed outside of the module. If set to 'true' this module will destroy any addons that were installed by other sources."
}
variable "cluster_config_endpoint_type" {
description = "Specify which type of endpoint to use for for cluster config access: 'default', 'private', 'vpe', 'link'. 'default' value will use the default endpoint of the cluster."
type = string
default = "default"
nullable = false # use default if null is passed in
validation {
error_message = "Invalid Endpoint Type! Valid values are 'default', 'private', 'vpe', or 'link'"
condition = contains(["default", "private", "vpe", "link"], var.cluster_config_endpoint_type)
}
}
##############################################################################