This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
schema_shoot.go
535 lines (525 loc) · 17.5 KB
/
schema_shoot.go
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
package shoot
import (
"github.com/hashicorp/terraform/helper/schema"
)
func addonsResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"kubernetes_dashboard": {
Type: schema.TypeList,
Description: "Kubernetes dashboard holds configuration settings for the kubernetes dashboard addon.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
"authentication_mode": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
"nginx_ingress": {
Type: schema.TypeList,
Description: "NginxIngress holds configuration settings for the nginx-ingress addon.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
},
}
}
func dNSResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
// "provider": {
// Type: schema.TypeString,
// Description: "Provider is the DNS provider type for the Shoot.",
// Optional: true,
// },
"domain": {
Type: schema.TypeString,
Description: "Domain is the external available domain of the Shoot cluster.",
Optional: true,
},
// "secret_name": {
// Type: schema.TypeString,
// Description: "SecretName is a name of a secret containing credentials for the stated domain and the provider.",
// Optional: true,
// },
},
}
}
func hibernationResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Description: "Enabled is true if Shoot is hibernated, false otherwise.",
Required: true,
},
"schedules": {
Type: schema.TypeList,
Description: "Schedules determine the hibernation schedules.",
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"start": {
Type: schema.TypeString,
Description: "Start is a Cron spec at which time a Shoot will be hibernated.",
Optional: true,
},
"end": {
Type: schema.TypeString,
Description: "End is a Cron spec at which time a Shoot will be woken up.",
Optional: true,
},
"location": {
Type: schema.TypeString,
Description: "Location is the time location in which both start and and shall be evaluated.",
Optional: true,
},
},
},
},
},
}
}
func kubernetesResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"allow_privileged_containers": {
Type: schema.TypeBool,
Description: "AllowPrivilegedContainers indicates whether privileged containers are allowed in the Shoot.",
Optional: true,
},
"kube_api_server": {
Type: schema.TypeList,
Description: "KubeAPIServer contains configuration settings for the kube-apiserver.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enable_basic_authentication": {
Type: schema.TypeBool,
Description: "enable basic authentication flag.",
Optional: true,
},
"oidc_config": {
Type: schema.TypeList,
Description: "interface for adding oidc_config in kube api server section",
MaxItems: 1,
Optional: true,
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ca_bundle": {
Type: schema.TypeString,
Description: "ca_bundle for oidc config in kube api server section",
Optional: true,
},
"client_id": {
Type: schema.TypeString,
Description: "client_id for oidc config in kube api server section",
Optional: true,
},
"groups_claim": {
Type: schema.TypeString,
Description: "groups_claim for oidc config in kube api server section",
Optional: true,
},
"groups_prefix": {
Type: schema.TypeString,
Description: "groups_prefix for oidc config in kube api server section",
Optional: true,
},
"issuer_url": {
Type: schema.TypeString,
Description: "issuer_url for oidc config in kube api server section",
Optional: true,
},
"required_claims": {
Type: schema.TypeMap,
Description: "required_claims for oidc config in kube api server section",
Optional: true,
},
"signing_algs": {
Type: schema.TypeSet,
Description: "signing_algs for oidc config in kube api server section",
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},
"username_claim": {
Type: schema.TypeString,
Description: "username_claim for oidc config in kube api server section",
Optional: true,
},
"username_prefix": {
Type: schema.TypeString,
Description: "username_prefix for oidc config in kube api server section",
Optional: true,
},
},
},
},
"audit_config": {
Type: schema.TypeList,
Description: "Audit Config contains customized audit config info.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"audit_policy": {
Type: schema.TypeList,
Description: "Audit Policy contains customized audit policy info.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"config_map_ref": {
Type: schema.TypeList,
Description: "Config Map Ref contains customized config map ref info.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Description: "name of the config map ref",
Optional: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
"kube_controller_manager": {
Type: schema.TypeList,
Description: "KubeControllerManager contains configuration settings for the kube-controller-manager.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_cidr_mask_size": {
Type: schema.TypeInt,
Description: "Size of the node mask.",
Optional: true,
},
},
},
},
"kube_proxy": {
Type: schema.TypeList,
Description: "KubeProxy contains configuration settings for the kube-proxy.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"mode": {
Type: schema.TypeString,
Description: "Mode specifies which proxy mode to use. defaults to IPTables.",
Optional: true,
Default: "IPTables",
},
},
},
},
"kubelet": {
Type: schema.TypeList,
Description: "Kubelet contains configuration settings for the kubelet.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"feature_gates": {
Type: schema.TypeMap,
Description: "FeatureGates contains information about enabled feature gates.",
Optional: true,
},
"pod_pids_limit": {
Type: schema.TypeInt,
Description: "PodPIDsLimit is the maximum number of process IDs per pod allowed by the kubelet.",
Optional: true,
},
"cpu_cfs_quota": {
Type: schema.TypeBool,
Description: "CPUCFSQuota allows you to disable/enable CPU throttling for Pods.",
Optional: true,
},
"cpu_manager_policy": {
Type: schema.TypeString,
Description: "CPUManagerPolicy allows to set alternative CPU management policies (default: none).",
Optional: true,
},
},
},
},
"version": {
Type: schema.TypeString,
Description: "Version is the semantic Kubernetes version to use for the Shoot cluster.",
Required: true,
},
"cluster_autoscaler": {
Type: schema.TypeList,
Description: "ClusterAutoscaler contains the configration flags for the Kubernetes cluster autoscaler.",
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"scale_down_utilization_threshold": {
Type: schema.TypeFloat,
Description: "ScaleDownUtilizationThreshold defines the threshold in % under which a node is being removed.",
Optional: true,
},
"scale_down_unneeded_time": {
Type: schema.TypeString,
Description: "ScaleDownUnneededTime defines how long a node should be unneeded before it is eligible for scale down (default: 10 mins).",
Optional: true,
},
"scale_down_delay_after_add": {
Type: schema.TypeString,
Description: "ScaleDownDelayAfterAdd defines how long after scale up that scale down evaluation resumes (default: 10 mins).",
Optional: true,
},
"scale_down_delay_after_failure": {
Type: schema.TypeString,
Description: "ScaleDownDelayAfterFailure how long after scale down failure that scale down evaluation resumes (default: 3 mins).",
Optional: true,
},
"scale_down_delay_after_delete": {
Type: schema.TypeString,
Description: "ScaleDownDelayAfterDelete how long after node deletion that scale down evaluation resumes, defaults to scanInterval (defaults to ScanInterval).",
Optional: true,
},
"scan_interval": {
Type: schema.TypeString,
Description: "ScanInterval how often cluster is reevaluated for scale up or down (default: 10 secs).",
Optional: true,
},
},
},
},
},
}
}
func maintenanceResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"auto_update": {
Type: schema.TypeList,
Description: "AutoUpdate contains information about which constraints should be automatically updated.",
MaxItems: 1,
Optional: true,
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"kubernetes_version": {
Type: schema.TypeBool,
Description: "KubernetesVersion indicates whether the patch Kubernetes version may be automatically updated.",
Optional: true,
Default: true,
},
"machine_image_version": {
Type: schema.TypeBool,
Description: "machineImageVersion indicates whether the machine image version may be automatically updated.",
Optional: true,
Default: true,
},
},
},
},
"time_window": {
Type: schema.TypeList,
Description: "TimeWindow contains information about the time window for maintenance operations.",
Optional: true,
MaxItems: 1,
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"begin": {
Type: schema.TypeString,
Description: "Begin is the beginning of the time window in the format HHMMSS+ZONE, e.g. '220000+0100'.",
Optional: true,
DiffSuppressFunc: suppressEmptyNewValue,
},
"end": {
Type: schema.TypeString,
Description: "End is the end of the time window in the format HHMMSS+ZONE, e.g. '220000+0100'.",
Optional: true,
DiffSuppressFunc: suppressEmptyNewValue,
},
},
},
},
},
}
}
func monitoringResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"alerting": {
Type: schema.TypeList,
Description: "Alert configuration to send notification to email lists.",
Optional: true,
MaxItems: 1,
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"emailreceivers": {
Type: schema.TypeSet,
Description: "List of people who receiving alerts for this shoots",
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
DiffSuppressFunc: suppressEmptyNewValue,
},
},
},
},
},
}
}
func shootSpecSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Description: "ShootSpec is the specification of a Shoot. (see https://github.com/gardener/gardener/blob/master/pkg/apis/garden/v1beta1/types.go#L609)",
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"addons": {
Type: schema.TypeList,
Description: "Addons contains information about enabled/disabled addons and their configuration.",
Optional: true,
MaxItems: 1,
Elem: addonsResource(),
},
"cloud_profile_name": {
Type: schema.TypeString,
Description: "Profile is a name of a CloudProfile object.",
Required: true,
},
"dns": {
Type: schema.TypeList,
Description: "DNS contains information about the DNS settings of the Shoot.",
Optional: true,
MaxItems: 1,
Elem: dNSResource(),
},
//"extensions": {
// Type: schema.TypeList,
// Description: "Extensions contain type and provider information for Shoot extensions.",
// Optional: true,
//},
"hibernation": {
Type: schema.TypeList,
Description: "Hibernation contains information whether the Shoot is suspended or not.",
Optional: true,
MaxItems: 1,
Elem: hibernationResource(),
},
"kubernetes": {
Type: schema.TypeList,
Description: "Kubernetes contains the version and configuration settings of the control plane components.",
Required: true,
MaxItems: 1,
Elem: kubernetesResource(),
},
"networking": {
Type: schema.TypeList,
Description: "Networking contains information about cluster networking such as CNI Plugin type, CIDRs, ...etc.",
Required: true,
Elem: networkingResource(),
},
"maintenance": {
Type: schema.TypeList,
Description: "Maintenance contains information about the time window for maintenance operations and which operations should be performed.",
Optional: true,
MaxItems: 1,
Elem: maintenanceResource(),
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
},
"monitoring": {
Type: schema.TypeList,
Description: "Alert configuration to send notification to email lists.",
Optional: true,
MaxItems: 1,
Elem: monitoringResource(),
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
},
"provider": {
Type: schema.TypeList,
Description: "Provider contains all provider-specific and provider-relevant information.",
Required: true,
Elem: providerResource(),
DiffSuppressFunc: suppressMissingOptionalConfigurationBlock,
},
"purpose": {
Type: schema.TypeString,
Description: "Purpose is the purpose class for this cluster.",
Optional: true,
},
"region": {
Type: schema.TypeString,
Description: "Region is a name of a cloud provider region.",
Required: true,
},
"secret_binding_name": {
Type: schema.TypeString,
Description: "Secret binding name is the name of the a SecretBinding that has a reference to the provider secret. The credentials inside the provider secret will be used to create the shoot in the respective account",
Required: true,
},
"seed_name": {
Type: schema.TypeString,
Description: "Seed name is the name of the seed cluster that runs the control plane of the Shoot.",
Optional: true,
},
},
},
}
}
func networkingResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Description: "Type identifies the type of the networking plugin.",
Required: true,
},
"pods": {
Type: schema.TypeString,
Description: "Pods is the CIDR of the pod network.",
Optional: true,
},
"nodes": {
Type: schema.TypeString,
Description: "Nodes is the CIDR of the entire node network.",
Optional: true,
},
"services": {
Type: schema.TypeString,
Description: "Services is the CIDR of the service network.",
Optional: true,
},
},
}
}