-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
361 lines (311 loc) · 9.93 KB
/
variables.tf
File metadata and controls
361 lines (311 loc) · 9.93 KB
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
variable "profile_folder" {
type = string
description = "Folder in which to create profile-specific files."
validation {
condition = var.profile_folder != null
error_message = "Profile folder cannot be empty."
}
}
variable "resource_name_prefix" {
type = string
description = "Prefix to be prepended to all resource names."
validation {
condition = var.resource_name_prefix != null && can(regex("^([a-z][a-z0-9-_]*)?$", var.resource_name_prefix))
error_message = "Invalid resource prefix."
}
}
# General libvirt configuration
variable "libvirt_provider_uri" {
type = string
description = "Libvirt provider's URI"
default = "qemu:///system"
}
variable "libvirt_resource_pool_location" {
type = string
description = "Location where resource pool will be initialized"
default = "/var/lib/libvirt/pools/"
validation {
condition = length(var.libvirt_resource_pool_location) != 0
error_message = "Libvirt resource pool location cannot be empty."
}
}
variable "libvirt_network_ipv4_cidr" {
type = string
description = "IPv4 CIDR of the libvirt network of the virtual machines."
validation {
condition = can(regex("^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}/([1-9]|[1-2][0-9]|3[0-2])$", var.libvirt_network_ipv4_cidr))
error_message = "Invalid IPv4 network CIDR."
}
}
variable "libvirt_network_ipv6_cidr" {
type = string
description = "IPv6 CIDR of the libvirt network of the virtual machines, or null to not specify any."
default = null
validation {
condition = var.libvirt_network_ipv6_cidr == null || can(regex("^[0-9a-f]{1,4}(:[0-9a-f]{1,4})+::/[0-9]+$", var.libvirt_network_ipv6_cidr))
error_message = "Invalid IPv6 network CIDR."
}
}
variable "libvirt_network_dns_domain" {
type = string
description = "DNS domain of the libvirt network of the virtual machines, or null if a domain name should be auto-generated."
default = null
validation {
condition = var.libvirt_network_dns_domain == null || can(regex("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$", var.libvirt_network_dns_domain))
error_message = "Invalid libvirt network DNS domain."
}
}
# General virtual machine configuration
variable "controller_image_source" {
type = string
description = "Controller image source, which can be a path on the host's filesystem or a URL."
default = "alpine-image/image.qcow2"
validation {
condition = length(var.controller_image_source) != 0
error_message = "Controller virtual machine image source is missing."
}
}
variable "worker_image_source" {
type = string
description = "Worker image source, which can be a path on the host's filesystem or a URL."
default = "alpine-image/image.qcow2"
validation {
condition = length(var.worker_image_source) != 0
error_message = "Worker virtual machine image source is missing."
}
}
variable "worker_cloudinit_extra_user_data" {
type = map(any)
description = "Extra cloud-init user data for worker nodes."
default = {}
validation {
condition = var.worker_cloudinit_extra_user_data != null
error_message = "Extra cloud-init user data for worker cannot be null."
}
}
variable "worker_cloudinit_extra_runcmds" {
type = list(string)
description = "Extra cloud-init runcmds for worker nodes."
default = []
validation {
condition = var.worker_cloudinit_extra_runcmds != null
error_message = "Extra cloud-init runcmds for worker nodes cannot be null."
}
}
variable "machine_user" {
type = string
description = "Username used to SSH into virtual machines."
default = "k0s"
}
# Controller node parameters
variable "controller_num_nodes" {
type = number
description = "The number controller nodes to spin up."
default = 1
}
variable "controller_num_cpus" {
type = number
description = "The number CPUs allocated to a controller node."
default = 1
}
variable "controller_memory" {
type = number
description = "The amount of RAM (in MiB) allocated to a controller node."
default = 1024
}
variable "controller_k0s_enable_worker" {
type = bool
description = "Whether k0s on the controllers should also schedule workloads."
default = false
}
# Worker node parameters
variable "worker_num_nodes" {
type = number
description = "The number worker nodes to spin up."
default = 1
}
variable "worker_num_cpus" {
type = number
description = "The number CPUs allocated to a worker node."
default = 1
}
variable "worker_memory" {
type = number
description = "The amount of RAM (in MiB) allocated to a worker node."
default = 1024
}
# Load balancer variables
variable "loadbalancer_enabled" {
type = bool
description = "Whether to use a load balancer in front of the control plane."
default = false
}
# k0s variables
variable "k0s_version" {
type = string
description = "The k0s version to deploy on the machines. May be an exact version, \"stable\" or \"latest\"."
default = "stable"
}
variable "k0s_dynamic_config" {
type = bool
description = "Whether to enable k0s dynamic configuration."
default = false
}
variable "k0s_config_spec" {
type = object({
api = optional(object({
extraArgs = map(string),
})),
extensions = optional(object({
helm = optional(object({
repositories = optional(list(
object({
name = string,
url = string,
caFile = optional(string),
certFile = optional(string),
insecure = optional(bool),
keyfile = optional(string),
username = optional(string),
password = optional(string),
}),
)),
charts = optional(list(
object({
name = string,
chartname = string,
version = optional(string),
values = optional(string),
namespace = string,
timeout = optional(string),
}),
)),
})),
})),
network = optional(object({
provider = optional(string),
calico = optional(map(string)),
podCIDR = optional(string),
serviceCIDR = optional(string),
kubeProxy = optional(object({
mode = optional(string),
})),
nodeLocalLoadBalancing = optional(object({
enabled = optional(bool),
type = optional(string),
envoyProxy = optional(object({
image = optional(object({
image = string,
version = string,
})),
port = optional(number),
})),
})),
})),
images = optional(map(map(object({
image = optional(string),
version = optional(string),
})))),
storage = optional(object({
type = optional(string),
etcd = optional(object({
peerAddress = string,
extraArgs = map(string),
externalCluster = optional(object({
endpoints = optional(string),
etcdPrefix = optional(string),
caFile = optional(string),
clientCertFile = optional(string),
clientKeyFile = optional(string),
})),
})),
kine = optional(object({
dataSource = optional(string),
})),
})),
workerProfiles = optional(list(object({
name = string,
values = any,
}))),
})
description = "The k0s config spec"
default = null
}
# k0sctl variables
variable "k0sctl_binary" {
type = string
description = "Path to the k0sctl binary to use for local-exec provisioning, or null to skip k0sctl resources."
default = "k0sctl"
}
variable "k0sctl_k0s_binary" {
type = string
description = "Path to the k0s binary to use, or null if it should be downloaded."
default = null
}
variable "k0sctl_airgap_image_bundle" {
type = string
description = <<-EOD
Path to the airgap image bundle to be copied to the worker-enabled nodes, or null
if it should be downloaded. See https://docs.k0sproject.io/head/airgap-install/
for details on that.
EOD
default = null
}
variable "k0sctl_additional_controller_files" {
type = list(object({
src = string
dstDir = string
name = string
perm = string
}))
nullable = false
description = "Additional files to be copied over to controller nodes."
default = []
}
variable "k0sctl_k0s_install_flags" {
type = list(string)
description = "Install flags to be passed to k0s."
default = []
validation {
condition = var.k0sctl_k0s_install_flags != null
error_message = "K0s install flags cannot be null."
}
}
variable "k0sctl_k0s_controller_install_flags" {
type = list(string)
description = "Install flags to be passed to k0s controllers."
default = []
validation {
condition = var.k0sctl_k0s_controller_install_flags != null
error_message = "K0s controller install flags cannot be null."
}
}
variable "k0sctl_k0s_controller_hooks" {
type = object({
apply = optional(object({
before = optional(list(string))
after = optional(list(string))
}))
})
description = "K0sctl hooks for k0s controllers."
default = {}
}
variable "k0sctl_k0s_worker_install_flags" {
type = list(string)
description = "Install flags to be passed to k0s workers."
default = []
validation {
condition = var.k0sctl_k0s_worker_install_flags != null
error_message = "K0s worker install flags cannot be null."
}
}
variable "k0sctl_k0s_worker_hooks" {
type = object({
apply = optional(object({
before = optional(list(string))
after = optional(list(string))
}))
})
description = "K0sctl hooks for k0s workers."
default = {}
}