diff --git a/pkg/model/gcemodel/autoscalinggroup.go b/pkg/model/gcemodel/autoscalinggroup.go index 20b8bd64e133f..1c59a9f4d3f71 100644 --- a/pkg/model/gcemodel/autoscalinggroup.go +++ b/pkg/model/gcemodel/autoscalinggroup.go @@ -332,13 +332,19 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e for zone, targetSize := range instanceCountByZone { name := gce.NameForInstanceGroupManager(b.Cluster.ObjectMeta.Name, ig.ObjectMeta.Name, zone) + updatePolicy := &gcetasks.UpdatePolicy{ + MaxSurgeFixed: 1, + MaxUnavailableFixed: 1, + MinimalAction: "REPLACE", + Type: "OPPORTUNISTIC", + } t := &gcetasks.InstanceGroupManager{ Name: s(name), Lifecycle: b.Lifecycle, Zone: s(zone), TargetSize: fi.PtrTo(int64(targetSize)), - UpdatePolicy: &gcetasks.UpdatePolicy{MinimalAction: "REPLACE", Type: "OPPORTUNISTIC"}, + UpdatePolicy: updatePolicy, BaseInstanceName: s(ig.ObjectMeta.Name), InstanceTemplate: instanceTemplate, ListManagedInstancesResults: "PAGINATED", diff --git a/tests/integration/update_cluster/ha_gce/kubernetes.tf b/tests/integration/update_cluster/ha_gce/kubernetes.tf index 96934ede7c847..3400db34a1422 100644 --- a/tests/integration/update_cluster/ha_gce/kubernetes.tf +++ b/tests/integration/update_cluster/ha_gce/kubernetes.tf @@ -501,8 +501,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-ha-gce-exa name = "a-master-us-test1-a-ha-gce-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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" { name = "a-nodes-ha-gce-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "b-master-us-test1-b-ha-gce-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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" { name = "b-nodes-ha-gce-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "c-master-us-test1-c-ha-gce-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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" { name = "c-nodes-ha-gce-example-com" target_size = 0 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-ha-gce-example-com.self_link diff --git a/tests/integration/update_cluster/many-addons-gce/kubernetes.tf b/tests/integration/update_cluster/many-addons-gce/kubernetes.tf index d750cfc967a5b..bb71a22e7e6bd 100644 --- a/tests/integration/update_cluster/many-addons-gce/kubernetes.tf +++ b/tests/integration/update_cluster/many-addons-gce/kubernetes.tf @@ -429,8 +429,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-ex name = "a-master-us-test1-a-minimal-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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" { name = "a-nodes-minimal-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-example-com.self_link diff --git a/tests/integration/update_cluster/minimal_gce/kubernetes.tf b/tests/integration/update_cluster/minimal_gce/kubernetes.tf index 738f36adbfe6f..610809f75cf84 100644 --- a/tests/integration/update_cluster/minimal_gce/kubernetes.tf +++ b/tests/integration/update_cluster/minimal_gce/kubernetes.tf @@ -405,8 +405,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc name = "a-master-us-test1-a-minimal-gce-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "a-nodes-minimal-gce-example-com" target_size = 2 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-gce-example-com.self_link diff --git a/tests/integration/update_cluster/minimal_gce_dns-none/kubernetes.tf b/tests/integration/update_cluster/minimal_gce_dns-none/kubernetes.tf index 16de2b85cb292..015eef5370a0a 100644 --- a/tests/integration/update_cluster/minimal_gce_dns-none/kubernetes.tf +++ b/tests/integration/update_cluster/minimal_gce_dns-none/kubernetes.tf @@ -469,8 +469,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc name = "a-master-us-test1-a-minimal-gce-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "a-nodes-minimal-gce-example-com" target_size = 2 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-gce-example-com.self_link diff --git a/tests/integration/update_cluster/minimal_gce_ilb/kubernetes.tf b/tests/integration/update_cluster/minimal_gce_ilb/kubernetes.tf index 0d5c877847501..ec4ef219f1696 100644 --- a/tests/integration/update_cluster/minimal_gce_ilb/kubernetes.tf +++ b/tests/integration/update_cluster/minimal_gce_ilb/kubernetes.tf @@ -438,8 +438,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc name = "a-master-us-test1-a-minimal-gce-ilb-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "a-nodes-minimal-gce-ilb-example-com" target_size = 2 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-gce-ilb-example-com.self_link diff --git a/tests/integration/update_cluster/minimal_gce_ilb_longclustername/kubernetes.tf b/tests/integration/update_cluster/minimal_gce_ilb_longclustername/kubernetes.tf index ad16c3f4d38bb..f164408a00333 100644 --- a/tests/integration/update_cluster/minimal_gce_ilb_longclustername/kubernetes.tf +++ b/tests/integration/update_cluster/minimal_gce_ilb_longclustername/kubernetes.tf @@ -438,8 +438,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc name = "a-master-us-test1-a-minimal-gce-with-a-very-very-very-ve-j0fh8f" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "a-nodes-minimal-gce-with-a-very-very-very-very-very-long-qk78uj" target_size = 2 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link diff --git a/tests/integration/update_cluster/minimal_gce_longclustername/kubernetes.tf b/tests/integration/update_cluster/minimal_gce_longclustername/kubernetes.tf index bf85d2e47cd17..1d100a9c24b61 100644 --- a/tests/integration/update_cluster/minimal_gce_longclustername/kubernetes.tf +++ b/tests/integration/update_cluster/minimal_gce_longclustername/kubernetes.tf @@ -405,8 +405,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc name = "a-master-us-test1-a-minimal-gce-with-a-very-very-very-ve-j0fh8f" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 @@ -423,8 +425,10 @@ resource "google_compute_instance_group_manager" "a-nodes-minimal-gce-with-a-ver name = "a-nodes-minimal-gce-with-a-very-very-very-very-very-long-qk78uj" target_size = 2 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-gce-with-a-very-very-very-very-very-long-name-example-com.self_link diff --git a/tests/integration/update_cluster/minimal_gce_plb/kubernetes.tf b/tests/integration/update_cluster/minimal_gce_plb/kubernetes.tf index 49ab7b00b580c..395f9383bd2cd 100644 --- a/tests/integration/update_cluster/minimal_gce_plb/kubernetes.tf +++ b/tests/integration/update_cluster/minimal_gce_plb/kubernetes.tf @@ -462,8 +462,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc target_pools = [google_compute_target_pool.api-minimal-gce-plb-example-com.self_link] target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "a-nodes-minimal-gce-plb-example-com" target_size = 2 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-gce-plb-example-com.self_link diff --git a/tests/integration/update_cluster/minimal_gce_private/kubernetes.tf b/tests/integration/update_cluster/minimal_gce_private/kubernetes.tf index 5c49ad915260f..d8939ea8651a8 100644 --- a/tests/integration/update_cluster/minimal_gce_private/kubernetes.tf +++ b/tests/integration/update_cluster/minimal_gce_private/kubernetes.tf @@ -405,8 +405,10 @@ resource "google_compute_instance_group_manager" "a-master-us-test1-a-minimal-gc name = "a-master-us-test1-a-minimal-gce-private-example-com" target_size = 1 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { 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 name = "a-nodes-minimal-gce-private-example-com" target_size = 2 update_policy { - minimal_action = "REPLACE" - type = "OPPORTUNISTIC" + max_surge_fixed = 1 + max_unavailable_fixed = 1 + minimal_action = "REPLACE" + type = "OPPORTUNISTIC" } version { instance_template = google_compute_instance_template.nodes-minimal-gce-private-example-com.self_link diff --git a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go index 5e0a68a02d964..2c7b36d02deb7 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go @@ -68,7 +68,12 @@ func (e *InstanceGroupManager) Find(c *fi.CloudupContext) (*InstanceGroupManager actual.ListManagedInstancesResults = r.ListManagedInstancesResults if policy := r.UpdatePolicy; policy != nil { - actual.UpdatePolicy = &UpdatePolicy{MinimalAction: policy.MinimalAction, Type: policy.Type} + actual.UpdatePolicy = &UpdatePolicy{ + MinimalAction: policy.MinimalAction, + Type: policy.Type, + MaxSurgeFixed: policy.MaxSurge.Fixed, + MaxUnavailableFixed: policy.MaxUnavailable.Fixed, + } } for _, targetPool := range r.TargetPools { @@ -111,8 +116,10 @@ func (_ *InstanceGroupManager) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Ins if policy := e.UpdatePolicy; policy != nil { i.UpdatePolicy = &compute.InstanceGroupManagerUpdatePolicy{ - MinimalAction: policy.MinimalAction, - Type: policy.Type, + MaxSurge: &compute.FixedOrPercent{Fixed: policy.MaxSurgeFixed}, + MaxUnavailable: &compute.FixedOrPercent{Fixed: policy.MaxUnavailableFixed}, + MinimalAction: policy.MinimalAction, + Type: policy.Type, } } @@ -199,8 +206,10 @@ type terraformInstanceGroupManager struct { } type terraformUpdatePolicy struct { - MinimalAction string `cty:"minimal_action"` - Type string `cty:"type"` + MaxSurgeFixed int64 `cty:"max_surge_fixed"` + MaxUnavailableFixed int64 `cty:"max_unavailable_fixed"` + MinimalAction string `cty:"minimal_action"` + Type string `cty:"type"` } type terraformVersion struct { @@ -220,8 +229,10 @@ func (_ *InstanceGroupManager) RenderTerraform(t *terraform.TerraformTarget, a, } if policy := e.UpdatePolicy; policy != nil { tf.UpdatePolicy = &terraformUpdatePolicy{ - MinimalAction: policy.MinimalAction, - Type: policy.Type, + MaxSurgeFixed: policy.MaxSurgeFixed, + MaxUnavailableFixed: policy.MaxUnavailableFixed, + MinimalAction: policy.MinimalAction, + Type: policy.Type, } } tf.Version = &terraformVersion{ diff --git a/upup/pkg/fi/cloudup/gcetasks/updatepolicy.go b/upup/pkg/fi/cloudup/gcetasks/updatepolicy.go index 8a65f9395e1ca..98dffc1e3cce4 100644 --- a/upup/pkg/fi/cloudup/gcetasks/updatepolicy.go +++ b/upup/pkg/fi/cloudup/gcetasks/updatepolicy.go @@ -20,6 +20,9 @@ import "k8s.io/kops/upup/pkg/fi" // UpdatePolicy represents a GCE instance group manager UpdatePolicy type UpdatePolicy struct { + MaxSurgeFixed int64 + MaxUnavailableFixed int64 + MinimalAction string Type string }