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;
|
// InstanceGroups is the list of instance groups to rolling-update;
|
||||||
// if not specified, all instance groups will be updated
|
// if not specified, all instance groups will be updated
|
||||||
InstanceGroups []string
|
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() {
|
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().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().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.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() {
|
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.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
|
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)
|
cloud, err := cloudup.BuildCloud(cluster)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ kops rolling-update cluster [flags]
|
||||||
--force Force rolling update, even if no changes
|
--force Force rolling update, even if no changes
|
||||||
-h, --help help for cluster
|
-h, --help help for cluster
|
||||||
--instance-group strings List of instance groups to update (defaults to all if not specified)
|
--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
|
-i, --interactive Prompt to continue after each instance is updated
|
||||||
--master-interval duration Time to wait between restarting masters (default 5m0s)
|
--master-interval duration Time to wait between restarting masters (default 5m0s)
|
||||||
--node-interval duration Time to wait between restarting nodes (default 4m0s)
|
--node-interval duration Time to wait between restarting nodes (default 4m0s)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue