-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
240 lines (212 loc) · 9.56 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
##############################################################################
# Input Variables
##############################################################################
variable "ibmcloud_api_key" {
description = "APIkey that's associated with the account to use, set via environment variable TF_VAR_ibmcloud_api_key"
type = string
sensitive = true
}
# 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."
}
# 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 "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)
labels = optional(map(string))
minSize = optional(number)
maxSize = optional(number)
enableAutoscaling = optional(bool)
boot_volume_encryption_kms_config = optional(object({
crk = string
kms_instance_id = string
kms_account_id = optional(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."
}
}
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 "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). This is only used during initial cluster provisioning, but ignored for future updates. Supports passing the string 'latest' (current latest available version) or 'default' (current IKS default recommended version). If no value is passed, it will default to 'default'."
default = null
validation {
condition = anytrue([
var.ocp_version == null,
var.ocp_version == "default",
var.ocp_version == "latest",
var.ocp_version == "4.12",
var.ocp_version == "4.13",
var.ocp_version == "4.14",
])
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. To change a public endpoint to private, create another cluster with the variable set to true or see [Switching to the private endpoint](https://cloud.ibm.com/docs/containers?topic=containers-cs_network_cluster#migrate-to-private-se)."
default = false
}
variable "ocp_entitlement" {
type = string
description = "Value that is applied to the entitlements for OCP cluster provisioning"
default = "cloud_pak"
}
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
})
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"
}
}
# 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)
})
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, 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"
default = null
}
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)
}
}
##############################################################################