mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 16:06:51 +00:00
Support rolling update to 0 desired replicas
Support a desired replica count of 0 for the new RC. Users sometimes want to roll out a new "inactive" template with the intent of scaling it up manually later.
This commit is contained in:
@@ -208,13 +208,20 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Further validation.
|
||||
if maxUnavailable == 0 && maxSurge == 0 {
|
||||
// Validate maximums.
|
||||
if desired > 0 && maxUnavailable == 0 && maxSurge == 0 {
|
||||
return fmt.Errorf("one of maxSurge or maxUnavailable must be specified")
|
||||
}
|
||||
// The minumum pods which must remain available througout the update
|
||||
// calculated for internal convenience.
|
||||
minAvailable := original - maxUnavailable
|
||||
minAvailable := int(math.Max(float64(0), float64(desired-maxUnavailable)))
|
||||
// If the desired new scale is 0, then the max unavailable is necessarily
|
||||
// the effective scale of the old RC regardless of the configuration
|
||||
// (equivalent to 100% maxUnavailable).
|
||||
if desired == 0 {
|
||||
maxUnavailable = original
|
||||
minAvailable = 0
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "Scaling up %s from %d to %d, scaling down %s from %d to 0 (keep %d pods available, don't exceed %d pods)\n",
|
||||
newRc.Name, newRc.Spec.Replicas, desired, oldRc.Name, oldRc.Spec.Replicas, minAvailable, original+maxSurge)
|
||||
|
||||
Reference in New Issue
Block a user