Skip to content

Commit

Permalink
Rolling-update features cordon/batch/detach
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaguilar committed Aug 15, 2019
1 parent 8568c64 commit c051617
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 24 deletions.
24 changes: 24 additions & 0 deletions cmd/kops/rollingupdatecluster.go
Expand Up @@ -142,12 +142,21 @@ type RollingUpdateOptions struct {
// InstanceGroupRoles is the list of roles we should rolling-update
// if not specified, all instance groups will be updated
InstanceGroupRoles []string

// Cordon will cordon all nodes scheduled for replacement so pods don't get scheduled on nodes that will soon terminate.
Cordon bool

// BatchSize size of instance to roll at a time
BatchSize int
// Detach will detach instance first instead of terminate
Detach bool
}

func (o *RollingUpdateOptions) InitDefaults() {
o.Yes = false
o.Force = false
o.CloudOnly = false
o.Cordon = false
o.FailOnDrainError = false
o.FailOnValidate = true

Expand All @@ -158,6 +167,9 @@ func (o *RollingUpdateOptions) InitDefaults() {

o.PostDrainDelay = 5 * time.Second
o.ValidationTimeout = 15 * time.Minute

o.BatchSize = 1
o.Detach = false
}

func NewCmdRollingUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
Expand All @@ -184,12 +196,21 @@ func NewCmdRollingUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().BoolVarP(&options.Interactive, "interactive", "i", options.Interactive, "Prompt to continue after each instance is updated")
cmd.Flags().StringSliceVar(&options.InstanceGroups, "instance-group", options.InstanceGroups, "List of instance groups to update (defaults to all if not specified)")
cmd.Flags().StringSliceVar(&options.InstanceGroupRoles, "instance-group-roles", options.InstanceGroupRoles, "If specified, only instance groups of the specified role will be updated (e.g. Master,Node,Bastion)")
cmd.Flags().BoolVar(&options.Detach, "detach", false, "Detaches the instance from the autoscale group. (AWS only)")

if featureflag.DrainAndValidateRollingUpdate.Enabled() {
cmd.Flags().BoolVar(&options.FailOnDrainError, "fail-on-drain-error", true, "The rolling-update will fail if draining a node fails.")
cmd.Flags().BoolVar(&options.FailOnValidate, "fail-on-validate-error", true, "The rolling-update will fail if the cluster fails to validate.")
}

if featureflag.CordonAllWhenRollingUpdate.Enabled() {
cmd.Flags().BoolVar(&options.Cordon, "cordon", false, "Cordon all nodes scheduled for replacement.")
}

if featureflag.BatchRollingUpdate.Enabled() {
cmd.Flags().IntVar(&options.BatchSize, "batch-size", 1, "Number of nodes to roll at a time.")
}

cmd.Run = func(cmd *cobra.Command, args []string) {
err := rootCommand.ProcessArgs(args)
if err != nil {
Expand Down Expand Up @@ -405,6 +426,9 @@ func RunRollingUpdateCluster(f *util.Factory, out io.Writer, options *RollingUpd
ClusterName: options.ClusterName,
PostDrainDelay: options.PostDrainDelay,
ValidationTimeout: options.ValidationTimeout,
Cordon: options.Cordon,
BatchSize: options.BatchSize,
Detach: options.Detach,
}
return d.RollingUpdate(groups, cluster, list)
}
3 changes: 3 additions & 0 deletions docs/cli/kops_rolling-update_cluster.md
Expand Up @@ -68,7 +68,10 @@ kops rolling-update cluster [flags]

```
--bastion-interval duration Time to wait between restarting bastions (default 15s)
--batch-size int Number of nodes to roll at a time. (default 1)
--cloudonly Perform rolling update without confirming progress with k8s
--cordon Cordon all nodes scheduled for replacement.
--detach Detaches the instance from the autoscale group. (AWS only)
--fail-on-drain-error The rolling-update will fail if draining a node fails. (default true)
--fail-on-validate-error The rolling-update will fail if the cluster fails to validate. (default true)
--force Force rolling update, even if no changes
Expand Down
4 changes: 4 additions & 0 deletions pkg/featureflag/featureflag.go
Expand Up @@ -51,6 +51,10 @@ var (
DNSPreCreate = New("DNSPreCreate", Bool(true))
// DrainAndValidateRollingUpdate if set will use new rolling update code that will drain and validate.
DrainAndValidateRollingUpdate = New("DrainAndValidateRollingUpdate", Bool(true))
// CordonAllWhenRollingUpdate if set will cordon all nodes scheduled for replacement.
CordonAllWhenRollingUpdate = New("CordonAllWhenRollingUpdate", Bool(true))
// BatchRollingUpdate set number of nodes to roll at a time
BatchRollingUpdate = New("BatchRollingUpdate", Bool(true))
// EnableLaunchTemplates indicates we wish to switch to using launch templates rather than launchconfigurations
EnableLaunchTemplates = New("EnableLaunchTemplates", Bool(false))
//EnableExternalCloudController toggles the use of cloud-controller-manager introduced in v1.7
Expand Down

0 comments on commit c051617

Please sign in to comment.