-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
187 lines (163 loc) · 4.15 KB
/
main.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
locals {
chart = "ocean-kubernetes-controller"
repository = "https://charts.spot.io"
}
resource "helm_release" "ocean-kubernetes-controller" {
# Whether to create the Ocean Controller
count = var.create_controller ? 1 : 0
# Chart details
chart = local.chart
version = var.chart_version
repository = local.repository
wait = var.wait
name = var.release_name
namespace = var.namespace
create_namespace = var.create_namespace
# Allow passing values from a file
values = [
var.values_file != null ? file(var.values_file) : "",
var.tolerations == null ? "" : "tolerations: ${jsonencode(var.tolerations)}",
var.node_selector == null ? "" : "nodeSelector: ${jsonencode(var.node_selector)}",
]
# ...Or set values directly from variables
dynamic "set_sensitive" {
for_each = var.spotinst_token != null ? [1] : []
content {
name = "spotinst.token"
value = var.spotinst_token
}
}
dynamic "set" {
for_each = var.spotinst_account != null ? [1] : []
content {
name = "spotinst.account"
value = var.spotinst_account
}
}
dynamic "set" {
for_each = var.cluster_identifier != null ? [1] : []
content {
name = "spotinst.clusterIdentifier"
value = var.cluster_identifier
}
}
dynamic "set" {
for_each = var.controller_image != null ? [1] : []
content {
name = "image.repository"
value = var.controller_image
}
}
dynamic "set" {
for_each = var.controller_version != null ? [1] : []
content {
name = "image.tag"
value = var.controller_version
}
}
dynamic "set" {
for_each = var.image_pull_policy != null ? [1] : []
content {
name = "image.pullPolicy"
value = var.image_pull_policy
}
}
dynamic "set" {
for_each = var.base_url != null ? [1] : []
content {
name = "spotinst.baseUrl"
value = var.base_url
}
}
dynamic "set" {
for_each = var.proxy_url != null ? [1] : []
content {
name = "spotinst.proxyUrl"
value = var.proxy_url
}
}
dynamic "set" {
for_each = var.enable_csr_approval != null ? [1] : []
content {
name = "spotinst.enableCsrApproval"
value = var.enable_csr_approval
}
}
dynamic "set" {
for_each = var.disable_auto_update != null ? [1] : []
content {
name = "spotinst.disableAutoUpdate"
value = var.disable_auto_update
}
}
dynamic "set" {
for_each = var.disable_rightsizing != null ? [1] : []
content {
name = "spotinst.disableAutomaticRightSizing"
value = var.disable_rightsizing
}
}
dynamic "set" {
for_each = var.image_pull_secrets
content {
name = "imagePullSecrets[${index(var.image_pull_secrets, set.value)}].name"
value = set.value
}
}
dynamic "set" {
for_each = var.resources_limits != null ? var.resources_limits : {}
content {
name = "resources.limits.${set.key}"
value = set.value
}
}
dynamic "set" {
for_each = var.resources_requests != null ? var.resources_requests : {}
content {
name = "resources.requests.${set.key}"
value = set.value
}
}
dynamic "set" {
for_each = var.secret_name != null ? [1] : []
content {
name = "secret.name"
value = var.secret_name
}
}
dynamic "set" {
for_each = var.service_account_name != null ? [1] : []
content {
name = "serviceAccount.name"
value = var.service_account_name
}
}
dynamic "set" {
for_each = var.config_map_name != null ? [1] : []
content {
name = "configMap.name"
value = var.config_map_name
}
}
dynamic "set" {
for_each = var.ca_bundle_secret_name != null ? [1] : []
content {
name = "caBundleSecret.name"
value = var.ca_bundle_secret_name
}
}
dynamic "set" {
for_each = var.deploy_metrics_server != null ? [1] : []
content {
name = "metrics-server.deployChart"
value = var.deploy_metrics_server
}
}
dynamic "set" {
for_each = var.replicas != null ? [1] : []
content {
name = "replicas"
value = var.replicas
}
}
}