forked from xunleii/terraform-module-k3s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
120 lines (109 loc) · 4.44 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
variable "depends_on_" {
description = "Resouce dependency of this module."
default = null
}
variable k3s_version {
description = "Specify the k3s version."
type = string
default = "latest"
}
variable name {
description = "K3s cluster domain name (see https://rancher.com/docs/k3s/latest/en/installation/install-options/)."
type = string
default = "cluster.local"
}
variable cidr {
description = "K3s network CIDRs (see https://rancher.com/docs/k3s/latest/en/installation/install-options/)."
type = object({
pods = string
services = string
})
default = {
pods = "10.42.0.0/16"
services = "10.43.0.0/16"
}
}
variable drain_timeout {
description = "The length of time to wait before giving up the node draining. Infinite by default."
type = string
default = "0s"
}
variable global_flags {
description = "Add additional installation flags, used by all nodes (see https://rancher.com/docs/k3s/latest/en/installation/install-options/)."
type = list(string)
default = []
}
variable servers {
description = "K3s server nodes definition. The key is used as node name if no name is provided."
type = map(any)
validation {
condition = length(var.servers) > 0
error_message = "At least one server node must be provided."
}
validation {
condition = length(var.servers) % 2 == 1
error_message = "Servers must have an odd number of nodes."
}
validation {
condition = can(values(var.servers)[*].ip)
error_message = "Field servers.<name>.ip is required."
}
validation {
condition = ! can(values(var.servers)[*].connection) || ! contains([for v in var.servers : can(tomap(v.connection))], false)
error_message = "Field servers.<name>.connection must be a valid Terraform connection."
}
validation {
condition = ! can(values(var.servers)[*].flags) || ! contains([for v in var.servers : can(tolist(v.flags))], false)
error_message = "Field servers.<name>.flags must be a list of string."
}
validation {
condition = ! can(values(var.servers)[*].annotations) || ! contains([for v in var.servers : can(tomap(v.annotations))], false)
error_message = "Field servers.<name>.annotations must be a map of string."
}
validation {
condition = ! can(values(var.servers)[*].labels) || ! contains([for v in var.servers : can(tomap(v.labels))], false)
error_message = "Field servers.<name>.labels must be a map of string."
}
validation {
condition = ! can(values(var.servers)[*].taints) || ! contains([for v in var.servers : can(tomap(v.taints))], false)
error_message = "Field servers.<name>.taints must be a map of string."
}
}
variable agents {
description = "K3s agent nodes definitions. The key is used as node name if no name is provided."
type = map(any)
default = {}
validation {
condition = can(values(var.agents)[*].ip)
error_message = "Field agents.<name>.ip is required."
}
validation {
condition = ! can(values(var.agents)[*].connection) || ! contains([for v in var.agents : can(tomap(v.connection))], false)
error_message = "Field agents.<name>.connection must be a valid Terraform connection."
}
validation {
condition = ! can(values(var.agents)[*].flags) || ! contains([for v in var.agents : can(tolist(v.flags))], false)
error_message = "Field agents.<name>.flags must be a list of string."
}
validation {
condition = ! can(values(var.agents)[*].annotations) || ! contains([for v in var.agents : can(tomap(v.annotations))], false)
error_message = "Field agents.<name>.annotations must be a map of string."
}
validation {
condition = ! can(values(var.agents)[*].labels) || ! contains([for v in var.agents : can(tomap(v.labels))], false)
error_message = "Field agents.<name>.labels must be a map of string."
}
validation {
condition = ! can(values(var.agents)[*].taints) || ! contains([for v in var.agents : can(tomap(v.taints))], false)
error_message = "Field agents.<name>.taints must be a map of string."
}
}
variable managed_fields {
description = "List of fields which must be managed by this module (can be annotation, label and/or taint)."
type = list(string)
default = ["annotation", "label", "taint"]
}
variable separator {
description = "Separator used to separates node name and field name (used to manage annotations, labels and taints)."
default = "|"
}