-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhorizontal_pod_autoscaler.tf
348 lines (255 loc) · 17.1 KB
/
horizontal_pod_autoscaler.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
348
resource "kubernetes_horizontal_pod_autoscaler" "instance" {
depends_on = [null_resource.module_depends_on]
for_each = local.horizontal_pod_autoscaler.applications
dynamic "metadata" { # Nesting Mode: list Min Items : 1 Max Items : 1
for_each = contains(keys(each.value), "metadata") ? {item = each.value["metadata"]} : {}
content {
annotations = lookup(metadata.value, "annotations", null)
# Type: ['map', 'string'] Optional
# An unstructured key value map stored with the horizontal pod autoscaler that may be used to store arbitrary metadata. More info: http://kubernetes.io/docs/user-guide/annotations
generate_name = lookup(metadata.value, "generateName", null)
# Type: string Optional
# Prefix, used by the server, to generate a unique name ONLY IF the `name` field has not been provided. This value will also be combined with a unique suffix. Read more: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#idempotency
labels = lookup(metadata.value, "labels", null)
# Type: ['map', 'string'] Optional
# Map of string keys and values that can be used to organize and categorize (scope and select) the horizontal pod autoscaler. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels
name = lookup(metadata.value, "name", null)
# Type: string Optional Computed
# Name of the horizontal pod autoscaler, must be unique. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names
namespace = var.namespace != "" ? var.namespace : lookup(metadata.value, "namespace", null)
# Type: string Optional
# Namespace defines the space within which name of the horizontal pod autoscaler must be unique.
}
}
dynamic "spec" { # Nesting Mode: list Min Items : 1 Max Items : 1
for_each = contains(keys(each.value), "spec") ? {item = each.value["spec"]} : {}
content {
max_replicas = lookup(spec.value, "maxReplicas", null)
# Type: number Required
# Upper limit for the number of pods that can be set by the autoscaler.
min_replicas = lookup(spec.value, "minReplicas", null)
# Type: number Optional
# Lower limit for the number of pods that can be set by the autoscaler, defaults to `1`.
target_cpu_utilization_percentage = lookup(spec.value, "targetCpuUtilizationPercentage", null)
# Type: number Optional Computed
# Target average CPU utilization (represented as a percentage of requested CPU) over all the pods. If not specified the default autoscaling policy will be used.
dynamic "metric" { # Nesting Mode: list
for_each = lookup(spec.value, "metrics", {})
content {
type = lookup(metric.value, "type", null)
# Type: string Required
# type is the type of metric source. It should be one of "Object", "Pods", "External" or "Resource", each mapping to a matching field in the object.
dynamic "external" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(metric.value), "external") ? {item = metric.value["external"]} : {}
content {
dynamic "metric" { # Nesting Mode: list Min Items : 1 Max Items : 1
for_each = contains(keys(external.value), "metric") ? {item = external.value["metric"]} : {}
content {
name = lookup(metric.value, "name", null)
# Type: string Required
# name is the name of the given metric
dynamic "selector" { # Nesting Mode: list
for_each = lookup(metric.value, "selector", {})
content {
match_labels = lookup(selector.value, "matchLabels", null)
# Type: ['map', 'string'] Optional
# A map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of `match_expressions`, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
dynamic "match_expressions" { # Nesting Mode: list
for_each = lookup(selector.value, "matchExpressions", {})
content {
key = lookup(match_expressions.value, "key", null)
# Type: string Optional
# The label key that the selector applies to.
operator = lookup(match_expressions.value, "operator", null)
# Type: string Optional
# A key's relationship to a set of values. Valid operators ard `In`, `NotIn`, `Exists` and `DoesNotExist`.
values = lookup(match_expressions.value, "values", null)
# Type: ['set', 'string'] Optional
# An array of string values. If the operator is `In` or `NotIn`, the values array must be non-empty. If the operator is `Exists` or `DoesNotExist`, the values array must be empty. This array is replaced during a strategic merge patch.
}
}
}
}
}
}
dynamic "target" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(external.value), "target") ? {item = external.value["target"]} : {}
content {
average_utilization = lookup(target.value, "averageUtilization", null)
# Type: number Optional
# averageUtilization is the target value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods. Currently only valid for Resource metric source type
average_value = lookup(target.value, "averageValue", null)
# Type: string Optional
# averageValue is the target value of the average of the metric across all relevant pods (as a quantity)
type = lookup(target.value, "type", null)
# Type: string Required
# type represents whether the metric type is Utilization, Value, or AverageValue
value = lookup(target.value, "value", null)
# Type: string Optional
# value is the target value of the metric (as a quantity).
}
}
}
}
dynamic "object" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(metric.value), "object") ? {item = metric.value["object"]} : {}
content {
dynamic "described_object" { # Nesting Mode: list Min Items : 1 Max Items : 1
for_each = contains(keys(object.value), "describedObject") ? {item = object.value["describedObject"]} : {}
content {
api_version = lookup(described_object.value, "apiVersion", null)
# Type: string Required
# API version of the referent
kind = lookup(described_object.value, "kind", null)
# Type: string Required
# Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
name = lookup(described_object.value, "name", null)
# Type: string Required
# Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names
}
}
dynamic "metric" { # Nesting Mode: list Min Items : 1 Max Items : 1
for_each = contains(keys(object.value), "metric") ? {item = object.value["metric"]} : {}
content {
name = lookup(metric.value, "name", null)
# Type: string Required
# name is the name of the given metric
dynamic "selector" { # Nesting Mode: list
for_each = lookup(metric.value, "selector", {})
content {
match_labels = lookup(selector.value, "matchLabels", null)
# Type: ['map', 'string'] Optional
# A map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of `match_expressions`, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
dynamic "match_expressions" { # Nesting Mode: list
for_each = lookup(selector.value, "matchExpressions", {})
content {
key = lookup(match_expressions.value, "key", null)
# Type: string Optional
# The label key that the selector applies to.
operator = lookup(match_expressions.value, "operator", null)
# Type: string Optional
# A key's relationship to a set of values. Valid operators ard `In`, `NotIn`, `Exists` and `DoesNotExist`.
values = lookup(match_expressions.value, "values", null)
# Type: ['set', 'string'] Optional
# An array of string values. If the operator is `In` or `NotIn`, the values array must be non-empty. If the operator is `Exists` or `DoesNotExist`, the values array must be empty. This array is replaced during a strategic merge patch.
}
}
}
}
}
}
dynamic "target" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(object.value), "target") ? {item = object.value["target"]} : {}
content {
average_utilization = lookup(target.value, "averageUtilization", null)
# Type: number Optional
# averageUtilization is the target value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods. Currently only valid for Resource metric source type
average_value = lookup(target.value, "averageValue", null)
# Type: string Optional
# averageValue is the target value of the average of the metric across all relevant pods (as a quantity)
type = lookup(target.value, "type", null)
# Type: string Required
# type represents whether the metric type is Utilization, Value, or AverageValue
value = lookup(target.value, "value", null)
# Type: string Optional
# value is the target value of the metric (as a quantity).
}
}
}
}
dynamic "pods" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(metric.value), "pods") ? {item = metric.value["pods"]} : {}
content {
dynamic "metric" { # Nesting Mode: list Min Items : 1 Max Items : 1
for_each = contains(keys(pods.value), "metric") ? {item = pods.value["metric"]} : {}
content {
name = lookup(metric.value, "name", null)
# Type: string Required
# name is the name of the given metric
dynamic "selector" { # Nesting Mode: list
for_each = lookup(metric.value, "selector", {})
content {
match_labels = lookup(selector.value, "matchLabels", null)
# Type: ['map', 'string'] Optional
# A map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of `match_expressions`, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
dynamic "match_expressions" { # Nesting Mode: list
for_each = lookup(selector.value, "matchExpressions", {})
content {
key = lookup(match_expressions.value, "key", null)
# Type: string Optional
# The label key that the selector applies to.
operator = lookup(match_expressions.value, "operator", null)
# Type: string Optional
# A key's relationship to a set of values. Valid operators ard `In`, `NotIn`, `Exists` and `DoesNotExist`.
values = lookup(match_expressions.value, "values", null)
# Type: ['set', 'string'] Optional
# An array of string values. If the operator is `In` or `NotIn`, the values array must be non-empty. If the operator is `Exists` or `DoesNotExist`, the values array must be empty. This array is replaced during a strategic merge patch.
}
}
}
}
}
}
dynamic "target" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(pods.value), "target") ? {item = pods.value["target"]} : {}
content {
average_utilization = lookup(target.value, "averageUtilization", null)
# Type: number Optional
# averageUtilization is the target value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods. Currently only valid for Resource metric source type
average_value = lookup(target.value, "averageValue", null)
# Type: string Optional
# averageValue is the target value of the average of the metric across all relevant pods (as a quantity)
type = lookup(target.value, "type", null)
# Type: string Required
# type represents whether the metric type is Utilization, Value, or AverageValue
value = lookup(target.value, "value", null)
# Type: string Optional
# value is the target value of the metric (as a quantity).
}
}
}
}
dynamic "resource" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(metric.value), "resource") ? {item = metric.value["resource"]} : {}
content {
name = lookup(resource.value, "name", null)
# Type: string Required
# name is the name of the resource in question.
dynamic "target" { # Nesting Mode: list Max Items : 1
for_each = contains(keys(resource.value), "target") ? {item = resource.value["target"]} : {}
content {
average_utilization = lookup(target.value, "averageUtilization", null)
# Type: number Optional
# averageUtilization is the target value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods. Currently only valid for Resource metric source type
average_value = lookup(target.value, "averageValue", null)
# Type: string Optional
# averageValue is the target value of the average of the metric across all relevant pods (as a quantity)
type = lookup(target.value, "type", null)
# Type: string Required
# type represents whether the metric type is Utilization, Value, or AverageValue
value = lookup(target.value, "value", null)
# Type: string Optional
# value is the target value of the metric (as a quantity).
}
}
}
}
}
}
dynamic "scale_target_ref" { # Nesting Mode: list Min Items : 1 Max Items : 1
for_each = contains(keys(spec.value), "scaleTargetRef") ? {item = spec.value["scaleTargetRef"]} : {}
content {
api_version = lookup(scale_target_ref.value, "apiVersion", null)
# Type: string Optional
# API version of the referent
kind = lookup(scale_target_ref.value, "kind", null)
# Type: string Required
# Kind of the referent. e.g. `ReplicationController`. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
name = lookup(scale_target_ref.value, "name", null)
# Type: string Required
# Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names
}
}
}
}
}