Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/model/gcemodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
36 changes: 24 additions & 12 deletions tests/integration/update_cluster/ha_gce/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/update_cluster/many-addons-gce/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/update_cluster/minimal_gce/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/update_cluster/minimal_gce_ilb/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/update_cluster/minimal_gce_plb/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
25 changes: 18 additions & 7 deletions upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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{
Expand Down
3 changes: 3 additions & 0 deletions upup/pkg/fi/cloudup/gcetasks/updatepolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading