Skip to content

Commit f42e52b

Browse files
committed
Specify required fixed MaxSurge and MaxUnavailable on MIGs
1 parent c95d2dc commit f42e52b

File tree

11 files changed

+108
-48
lines changed

11 files changed

+108
-48
lines changed

pkg/model/gcemodel/autoscalinggroup.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,19 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e
332332

333333
for zone, targetSize := range instanceCountByZone {
334334
name := gce.NameForInstanceGroupManager(b.Cluster.ObjectMeta.Name, ig.ObjectMeta.Name, zone)
335+
updatePolicy := &gcetasks.UpdatePolicy{
336+
MaxSurgeFixed: 1,
337+
MaxUnavailableFixed: 1,
338+
MinimalAction: "REPLACE",
339+
Type: "OPPORTUNISTIC",
340+
}
335341

336342
t := &gcetasks.InstanceGroupManager{
337343
Name: s(name),
338344
Lifecycle: b.Lifecycle,
339345
Zone: s(zone),
340346
TargetSize: fi.PtrTo(int64(targetSize)),
341-
UpdatePolicy: &gcetasks.UpdatePolicy{MinimalAction: "REPLACE", Type: "OPPORTUNISTIC"},
347+
UpdatePolicy: updatePolicy,
342348
BaseInstanceName: s(ig.ObjectMeta.Name),
343349
InstanceTemplate: instanceTemplate,
344350
ListManagedInstancesResults: "PAGINATED",

tests/integration/update_cluster/ha_gce/kubernetes.tf

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-ha-gce-exa
501501
name = "a-master-us-test1-a-ha-gce-example-com"
502502
target_size = 1
503503
update_policy {
504-
minimal_action = "REPLACE"
505-
type = "OPPORTUNISTIC"
504+
max_surge_fixed = 1
505+
max_unavailable_fixed = 1
506+
minimal_action = "REPLACE"
507+
type = "OPPORTUNISTIC"
506508
}
507509
version {
508510
instance_template = google_compute_instance_template.master-us-test1-a-ha-gce-example-com.self_link
@@ -519,8 +521,10 @@ resource "google_compute_instance_group_manager" "a-nodes-ha-gce-example-com" {
519521
name = "a-nodes-ha-gce-example-com"
520522
target_size = 1
521523
update_policy {
522-
minimal_action = "REPLACE"
523-
type = "OPPORTUNISTIC"
524+
max_surge_fixed = 1
525+
max_unavailable_fixed = 1
526+
minimal_action = "REPLACE"
527+
type = "OPPORTUNISTIC"
524528
}
525529
version {
526530
instance_template = google_compute_instance_template.nodes-ha-gce-example-com.self_link
@@ -537,8 +541,10 @@ resource "google_compute_instance_group_manager" "b-master-us-test1-b-ha-gce-exa
537541
name = "b-master-us-test1-b-ha-gce-example-com"
538542
target_size = 1
539543
update_policy {
540-
minimal_action = "REPLACE"
541-
type = "OPPORTUNISTIC"
544+
max_surge_fixed = 1
545+
max_unavailable_fixed = 1
546+
minimal_action = "REPLACE"
547+
type = "OPPORTUNISTIC"
542548
}
543549
version {
544550
instance_template = google_compute_instance_template.master-us-test1-b-ha-gce-example-com.self_link
@@ -555,8 +561,10 @@ resource "google_compute_instance_group_manager" "b-nodes-ha-gce-example-com" {
555561
name = "b-nodes-ha-gce-example-com"
556562
target_size = 1
557563
update_policy {
558-
minimal_action = "REPLACE"
559-
type = "OPPORTUNISTIC"
564+
max_surge_fixed = 1
565+
max_unavailable_fixed = 1
566+
minimal_action = "REPLACE"
567+
type = "OPPORTUNISTIC"
560568
}
561569
version {
562570
instance_template = google_compute_instance_template.nodes-ha-gce-example-com.self_link
@@ -573,8 +581,10 @@ resource "google_compute_instance_group_manager" "c-master-us-test1-c-ha-gce-exa
573581
name = "c-master-us-test1-c-ha-gce-example-com"
574582
target_size = 1
575583
update_policy {
576-
minimal_action = "REPLACE"
577-
type = "OPPORTUNISTIC"
584+
max_surge_fixed = 1
585+
max_unavailable_fixed = 1
586+
minimal_action = "REPLACE"
587+
type = "OPPORTUNISTIC"
578588
}
579589
version {
580590
instance_template = google_compute_instance_template.master-us-test1-c-ha-gce-example-com.self_link
@@ -591,8 +601,10 @@ resource "google_compute_instance_group_manager" "c-nodes-ha-gce-example-com" {
591601
name = "c-nodes-ha-gce-example-com"
592602
target_size = 0
593603
update_policy {
594-
minimal_action = "REPLACE"
595-
type = "OPPORTUNISTIC"
604+
max_surge_fixed = 1
605+
max_unavailable_fixed = 1
606+
minimal_action = "REPLACE"
607+
type = "OPPORTUNISTIC"
596608
}
597609
version {
598610
instance_template = google_compute_instance_template.nodes-ha-gce-example-com.self_link

tests/integration/update_cluster/many-addons-gce/kubernetes.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-ex
429429
name = "a-master-us-test1-a-minimal-example-com"
430430
target_size = 1
431431
update_policy {
432-
minimal_action = "REPLACE"
433-
type = "OPPORTUNISTIC"
432+
max_surge_fixed = 1
433+
max_unavailable_fixed = 1
434+
minimal_action = "REPLACE"
435+
type = "OPPORTUNISTIC"
434436
}
435437
version {
436438
instance_template = google_compute_instance_template.master-us-test1-a-minimal-example-com.self_link
@@ -447,8 +449,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-example-com" {
447449
name = "a-nodes-minimal-example-com"
448450
target_size = 1
449451
update_policy {
450-
minimal_action = "REPLACE"
451-
type = "OPPORTUNISTIC"
452+
max_surge_fixed = 1
453+
max_unavailable_fixed = 1
454+
minimal_action = "REPLACE"
455+
type = "OPPORTUNISTIC"
452456
}
453457
version {
454458
instance_template = google_compute_instance_template.nodes-minimal-example-com.self_link

tests/integration/update_cluster/minimal_gce/kubernetes.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
405405
name = "a-master-us-test1-a-minimal-gce-example-com"
406406
target_size = 1
407407
update_policy {
408-
minimal_action = "REPLACE"
409-
type = "OPPORTUNISTIC"
408+
max_surge_fixed = 1
409+
max_unavailable_fixed = 1
410+
minimal_action = "REPLACE"
411+
type = "OPPORTUNISTIC"
410412
}
411413
version {
412414
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-example-com.self_link
@@ -423,8 +425,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-example-co
423425
name = "a-nodes-minimal-gce-example-com"
424426
target_size = 2
425427
update_policy {
426-
minimal_action = "REPLACE"
427-
type = "OPPORTUNISTIC"
428+
max_surge_fixed = 1
429+
max_unavailable_fixed = 1
430+
minimal_action = "REPLACE"
431+
type = "OPPORTUNISTIC"
428432
}
429433
version {
430434
instance_template = google_compute_instance_template.nodes-minimal-gce-example-com.self_link

tests/integration/update_cluster/minimal_gce_dns-none/kubernetes.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
469469
name = "a-master-us-test1-a-minimal-gce-example-com"
470470
target_size = 1
471471
update_policy {
472-
minimal_action = "REPLACE"
473-
type = "OPPORTUNISTIC"
472+
max_surge_fixed = 1
473+
max_unavailable_fixed = 1
474+
minimal_action = "REPLACE"
475+
type = "OPPORTUNISTIC"
474476
}
475477
version {
476478
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-example-com.self_link
@@ -487,8 +489,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-example-co
487489
name = "a-nodes-minimal-gce-example-com"
488490
target_size = 2
489491
update_policy {
490-
minimal_action = "REPLACE"
491-
type = "OPPORTUNISTIC"
492+
max_surge_fixed = 1
493+
max_unavailable_fixed = 1
494+
minimal_action = "REPLACE"
495+
type = "OPPORTUNISTIC"
492496
}
493497
version {
494498
instance_template = google_compute_instance_template.nodes-minimal-gce-example-com.self_link

tests/integration/update_cluster/minimal_gce_ilb/kubernetes.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
438438
name = "a-master-us-test1-a-minimal-gce-ilb-example-com"
439439
target_size = 1
440440
update_policy {
441-
minimal_action = "REPLACE"
442-
type = "OPPORTUNISTIC"
441+
max_surge_fixed = 1
442+
max_unavailable_fixed = 1
443+
minimal_action = "REPLACE"
444+
type = "OPPORTUNISTIC"
443445
}
444446
version {
445447
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-ilb-example-com.self_link
@@ -456,8 +458,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-ilb-exampl
456458
name = "a-nodes-minimal-gce-ilb-example-com"
457459
target_size = 2
458460
update_policy {
459-
minimal_action = "REPLACE"
460-
type = "OPPORTUNISTIC"
461+
max_surge_fixed = 1
462+
max_unavailable_fixed = 1
463+
minimal_action = "REPLACE"
464+
type = "OPPORTUNISTIC"
461465
}
462466
version {
463467
instance_template = google_compute_instance_template.nodes-minimal-gce-ilb-example-com.self_link

tests/integration/update_cluster/minimal_gce_ilb_longclustername/kubernetes.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
438438
name = "a-master-us-test1-a-minimal-gce-with-a-very-very-very-ve-j0fh8f"
439439
target_size = 1
440440
update_policy {
441-
minimal_action = "REPLACE"
442-
type = "OPPORTUNISTIC"
441+
max_surge_fixed = 1
442+
max_unavailable_fixed = 1
443+
minimal_action = "REPLACE"
444+
type = "OPPORTUNISTIC"
443445
}
444446
version {
445447
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link
@@ -456,8 +458,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-with-a-ver
456458
name = "a-nodes-minimal-gce-with-a-very-very-very-very-very-long-qk78uj"
457459
target_size = 2
458460
update_policy {
459-
minimal_action = "REPLACE"
460-
type = "OPPORTUNISTIC"
461+
max_surge_fixed = 1
462+
max_unavailable_fixed = 1
463+
minimal_action = "REPLACE"
464+
type = "OPPORTUNISTIC"
461465
}
462466
version {
463467
instance_template = google_compute_instance_template.nodes-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link

tests/integration/update_cluster/minimal_gce_plb/kubernetes.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
462462
target_pools = [google_compute_target_pool.api-minimal-gce-plb-example-com.self_link]
463463
target_size = 1
464464
update_policy {
465-
minimal_action = "REPLACE"
466-
type = "OPPORTUNISTIC"
465+
max_surge_fixed = 1
466+
max_unavailable_fixed = 1
467+
minimal_action = "REPLACE"
468+
type = "OPPORTUNISTIC"
467469
}
468470
version {
469471
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-plb-example-com.self_link
@@ -480,8 +482,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-plb-exampl
480482
name = "a-nodes-minimal-gce-plb-example-com"
481483
target_size = 2
482484
update_policy {
483-
minimal_action = "REPLACE"
484-
type = "OPPORTUNISTIC"
485+
max_surge_fixed = 1
486+
max_unavailable_fixed = 1
487+
minimal_action = "REPLACE"
488+
type = "OPPORTUNISTIC"
485489
}
486490
version {
487491
instance_template = google_compute_instance_template.nodes-minimal-gce-plb-example-com.self_link

tests/integration/update_cluster/minimal_gce_private/kubernetes.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc
405405
name = "a-master-us-test1-a-minimal-gce-private-example-com"
406406
target_size = 1
407407
update_policy {
408-
minimal_action = "REPLACE"
409-
type = "OPPORTUNISTIC"
408+
max_surge_fixed = 1
409+
max_unavailable_fixed = 1
410+
minimal_action = "REPLACE"
411+
type = "OPPORTUNISTIC"
410412
}
411413
version {
412414
instance_template = google_compute_instance_template.master-us-test1-a-minimal-gce-private-example-com.self_link
@@ -423,8 +425,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-private-ex
423425
name = "a-nodes-minimal-gce-private-example-com"
424426
target_size = 2
425427
update_policy {
426-
minimal_action = "REPLACE"
427-
type = "OPPORTUNISTIC"
428+
max_surge_fixed = 1
429+
max_unavailable_fixed = 1
430+
minimal_action = "REPLACE"
431+
type = "OPPORTUNISTIC"
428432
}
429433
version {
430434
instance_template = google_compute_instance_template.nodes-minimal-gce-private-example-com.self_link

upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ func (e *InstanceGroupManager) Find(c *fi.CloudupContext) (*InstanceGroupManager
6868
actual.ListManagedInstancesResults = r.ListManagedInstancesResults
6969

7070
if policy := r.UpdatePolicy; policy != nil {
71-
actual.UpdatePolicy = &UpdatePolicy{MinimalAction: policy.MinimalAction, Type: policy.Type}
71+
actual.UpdatePolicy = &UpdatePolicy{
72+
MinimalAction: policy.MinimalAction,
73+
Type: policy.Type,
74+
MaxSurgeFixed: policy.MaxSurge.Fixed,
75+
MaxUnavailableFixed: policy.MaxUnavailable.Fixed,
76+
}
7277
}
7378

7479
for _, targetPool := range r.TargetPools {
@@ -111,8 +116,10 @@ func (_ *InstanceGroupManager) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Ins
111116

112117
if policy := e.UpdatePolicy; policy != nil {
113118
i.UpdatePolicy = &compute.InstanceGroupManagerUpdatePolicy{
114-
MinimalAction: policy.MinimalAction,
115-
Type: policy.Type,
119+
MaxSurge: &compute.FixedOrPercent{Fixed: policy.MaxSurgeFixed},
120+
MaxUnavailable: &compute.FixedOrPercent{Fixed: policy.MaxUnavailableFixed},
121+
MinimalAction: policy.MinimalAction,
122+
Type: policy.Type,
116123
}
117124
}
118125

@@ -199,8 +206,10 @@ type terraformInstanceGroupManager struct {
199206
}
200207

201208
type terraformUpdatePolicy struct {
202-
MinimalAction string `cty:"minimal_action"`
203-
Type string `cty:"type"`
209+
MaxSurgeFixed int64 `cty:"max_surge_fixed"`
210+
MaxUnavailableFixed int64 `cty:"max_unavailable_fixed"`
211+
MinimalAction string `cty:"minimal_action"`
212+
Type string `cty:"type"`
204213
}
205214

206215
type terraformVersion struct {
@@ -220,8 +229,10 @@ func (_ *InstanceGroupManager) RenderTerraform(t *terraform.TerraformTarget, a,
220229
}
221230
if policy := e.UpdatePolicy; policy != nil {
222231
tf.UpdatePolicy = &terraformUpdatePolicy{
223-
MinimalAction: policy.MinimalAction,
224-
Type: policy.Type,
232+
MaxSurgeFixed: policy.MaxSurgeFixed,
233+
MaxUnavailableFixed: policy.MaxUnavailableFixed,
234+
MinimalAction: policy.MinimalAction,
235+
Type: policy.Type,
225236
}
226237
}
227238
tf.Version = &terraformVersion{

0 commit comments

Comments
 (0)