Default maxSurge to 1 on AWS

This commit is contained in:
John Gardiner Myers 2020-03-04 19:22:47 -08:00
parent a5dabf58dc
commit e104cdb982
8 changed files with 30 additions and 13 deletions

View File

@ -2947,10 +2947,10 @@ spec:
example 10%). The absolute number is calculated from a percentage
by rounding up. A value of 0 for both this and MaxUnavailable
disables rolling updates. Has no effect on instance groups with
role "Master". Defaults to 0. Example: when this is set to 30%,
the InstanceGroup can be scaled up immediately when the rolling
update starts, such that the total number of old and new nodes
do not exceed 130% of desired nodes.'
role "Master". Defaults to 1 on AWS, 0 otherwise. Example: when
this is set to 30%, the InstanceGroup can be scaled up immediately
when the rolling update starts, such that the total number of
old and new nodes do not exceed 130% of desired nodes.'
maxUnavailable:
anyOf:
- type: string

View File

@ -640,10 +640,10 @@ spec:
example 10%). The absolute number is calculated from a percentage
by rounding up. A value of 0 for both this and MaxUnavailable
disables rolling updates. Has no effect on instance groups with
role "Master". Defaults to 0. Example: when this is set to 30%,
the InstanceGroup can be scaled up immediately when the rolling
update starts, such that the total number of old and new nodes
do not exceed 130% of desired nodes.'
role "Master". Defaults to 1 on AWS, 0 otherwise. Example: when
this is set to 30%, the InstanceGroup can be scaled up immediately
when the rolling update starts, such that the total number of
old and new nodes do not exceed 130% of desired nodes.'
maxUnavailable:
anyOf:
- type: string

View File

@ -700,7 +700,7 @@ type RollingUpdate struct {
// The absolute number is calculated from a percentage by rounding up.
// A value of 0 for both this and MaxUnavailable disables rolling updates.
// Has no effect on instance groups with role "Master".
// Defaults to 0.
// Defaults to 1 on AWS, 0 otherwise.
// Example: when this is set to 30%, the InstanceGroup can be scaled
// up immediately when the rolling update starts, such that the total
// number of old and new nodes do not exceed 130% of desired

View File

@ -582,7 +582,7 @@ type RollingUpdate struct {
// The absolute number is calculated from a percentage by rounding up.
// A value of 0 for both this and MaxUnavailable disables rolling updates.
// Has no effect on instance groups with role "Master".
// Defaults to 0.
// Defaults to 1 on AWS, 0 otherwise.
// Example: when this is set to 30%, the InstanceGroup can be scaled
// up immediately when the rolling update starts, such that the total
// number of old and new nodes do not exceed 130% of desired

View File

@ -595,7 +595,7 @@ type RollingUpdate struct {
// The absolute number is calculated from a percentage by rounding up.
// A value of 0 for both this and MaxUnavailable disables rolling updates.
// Has no effect on instance groups with role "Master".
// Defaults to 0.
// Defaults to 1 on AWS, 0 otherwise.
// Example: when this is set to 30%, the InstanceGroup can be scaled
// up immediately when the rolling update starts, such that the total
// number of old and new nodes do not exceed 130% of desired

View File

@ -15,6 +15,7 @@ go_library(
"//pkg/client/simple:go_default_library",
"//pkg/cloudinstances:go_default_library",
"//pkg/drain:go_default_library",
"//pkg/featureflag:go_default_library",
"//pkg/validation:go_default_library",
"//upup/pkg/fi:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",

View File

@ -19,6 +19,7 @@ package instancegroups
import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/featureflag"
)
func resolveSettings(cluster *kops.Cluster, group *kops.InstanceGroup, numInstances int) kops.RollingUpdate {
@ -37,8 +38,11 @@ func resolveSettings(cluster *kops.Cluster, group *kops.InstanceGroup, numInstan
}
if rollingUpdate.MaxSurge == nil {
zero := intstr.FromInt(0)
rollingUpdate.MaxSurge = &zero
val := intstr.FromInt(0)
if kops.CloudProviderID(cluster.Spec.CloudProvider) == kops.CloudProviderAWS && !featureflag.Spotinst.Enabled() {
val = intstr.FromInt(1)
}
rollingUpdate.MaxSurge = &val
}
if rollingUpdate.MaxSurge.Type == intstr.String {

View File

@ -204,3 +204,15 @@ func TestMaxSurge(t *testing.T) {
})
}
}
func TestAWSDefault(t *testing.T) {
resolved := resolveSettings(&kops.Cluster{
Spec: kops.ClusterSpec{
CloudProvider: "aws",
},
}, &kops.InstanceGroup{}, 1000)
assert.Equal(t, intstr.Int, resolved.MaxSurge.Type)
assert.Equal(t, int32(1), resolved.MaxSurge.IntVal)
assert.Equal(t, intstr.Int, resolved.MaxUnavailable.Type)
assert.Equal(t, int32(0), resolved.MaxUnavailable.IntVal)
}