mirror of https://github.com/kubernetes/kops.git
Merge pull request #5122 from justinsb/rolling_update_by_role
Allow rolling-update to filter on roles
This commit is contained in:
commit
cbf7b0886e
|
|
@ -137,6 +137,10 @@ type RollingUpdateOptions struct {
|
|||
// InstanceGroups is the list of instance groups to rolling-update;
|
||||
// if not specified, all instance groups will be updated
|
||||
InstanceGroups []string
|
||||
|
||||
// InstanceGroupRoles is the list of roles we should rolling-update
|
||||
// if not specified, all instance groups will be updated
|
||||
InstanceGroupRoles []string
|
||||
}
|
||||
|
||||
func (o *RollingUpdateOptions) InitDefaults() {
|
||||
|
|
@ -177,6 +181,7 @@ func NewCmdRollingUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
|
|||
cmd.Flags().DurationVar(&options.BastionInterval, "bastion-interval", options.BastionInterval, "Time to wait between restarting bastions")
|
||||
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")
|
||||
|
||||
if featureflag.DrainAndValidateRollingUpdate.Enabled() {
|
||||
cmd.Flags().BoolVar(&options.FailOnDrainError, "fail-on-drain-error", true, "The rolling-update will fail if draining a node fails.")
|
||||
|
|
@ -285,6 +290,24 @@ func RunRollingUpdateCluster(f *util.Factory, out io.Writer, options *RollingUpd
|
|||
warnUnmatched = false
|
||||
}
|
||||
|
||||
if len(options.InstanceGroupRoles) != 0 {
|
||||
var filtered []*api.InstanceGroup
|
||||
|
||||
for _, ig := range instanceGroups {
|
||||
for _, role := range options.InstanceGroupRoles {
|
||||
if ig.Spec.Role == api.InstanceGroupRole(role) {
|
||||
filtered = append(filtered, ig)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
instanceGroups = filtered
|
||||
|
||||
// Don't warn if we find more ASGs than IGs
|
||||
warnUnmatched = false
|
||||
}
|
||||
|
||||
cloud, err := cloudup.BuildCloud(cluster)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -67,17 +67,18 @@ kops rolling-update cluster [flags]
|
|||
### Options
|
||||
|
||||
```
|
||||
--bastion-interval duration Time to wait between restarting bastions (default 5m0s)
|
||||
--cloudonly Perform rolling update without confirming progress with k8s
|
||||
--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
|
||||
-h, --help help for cluster
|
||||
--instance-group strings List of instance groups to update (defaults to all if not specified)
|
||||
-i, --interactive Prompt to continue after each instance is updated
|
||||
--master-interval duration Time to wait between restarting masters (default 5m0s)
|
||||
--node-interval duration Time to wait between restarting nodes (default 4m0s)
|
||||
-y, --yes Perform rolling update immediately, without --yes rolling-update executes a dry-run
|
||||
--bastion-interval duration Time to wait between restarting bastions (default 5m0s)
|
||||
--cloudonly Perform rolling update without confirming progress with k8s
|
||||
--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
|
||||
-h, --help help for cluster
|
||||
--instance-group strings List of instance groups to update (defaults to all if not specified)
|
||||
--instance-group-roles strings If specified, only instance groups of the specified role will be updated
|
||||
-i, --interactive Prompt to continue after each instance is updated
|
||||
--master-interval duration Time to wait between restarting masters (default 5m0s)
|
||||
--node-interval duration Time to wait between restarting nodes (default 4m0s)
|
||||
-y, --yes Perform rolling update immediately, without --yes rolling-update executes a dry-run
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
|
|
|||
Loading…
Reference in New Issue