Practical technical guides / Core IT: cloud infrastructure

Rolling Update Percentages Round in Opposite Directions on Small Deployments

maxSurge rounds up and maxUnavailable rounds down. At three replicas the defaults give a surge-only rollout, and 0% surge forces one pod unavailable.

By Sandeep Belgavi · Published 2026-12-04 · Prepared 2026-12-03

maxSurge rounds up and maxUnavailable rounds down. At three replicas the defaults give a surge-only rollout, and 0% surge forces one pod unavailable.

Percentages are rounded, and the rounding has a direction

A Kubernetes Deployment with the default rolling update strategy replaces pods gradually, bounded by two settings: maxSurge, how many pods may exist above the desired count, and maxUnavailable, how many of the desired pods may be unavailable during the update. Both default to 25%, and both can be absolute numbers or percentages.

Percentages are where teams get surprised. A replica count is an integer, so 25% of three replicas has to become a whole number of pods, and the controller rounds the two settings in opposite directions. The Kubernetes documentation says so in the Deployment reference: the absolute number for maxUnavailable is calculated from the percentage by rounding down, and for maxSurge by rounding up. The deployment controller implements this in a function called ResolveFenceposts in pkg/controller/deployment/util/deployment_util.go, which also contains one more rule that the documentation describes only from the validation side.

For small deployments, those two roundings change the behaviour of a rollout in ways that matter for capacity planning, quotas and availability.

How the controller resolves the two values

The logic is short enough to restate in a few lines. This is a Python transcription for exploring values, not the controller's code.

import math

def resolve(value, replicas, round_up):
    """An int is used as is; a percentage is scaled by replicas and rounded."""
    if isinstance(value, int):
        return value
    exact = int(value.rstrip("%")) * replicas / 100
    return math.ceil(exact) if round_up else math.floor(exact)

def fenceposts(replicas, max_surge="25%", max_unavailable="25%"):
    surge = resolve(max_surge, replicas, round_up=True)
    unavailable = resolve(max_unavailable, replicas, round_up=False)
    if surge == 0 and unavailable == 0:
        unavailable = 1   # without this, a rollout could never make progress
    return surge, unavailable

print([fenceposts(n) for n in (1, 2, 3, 4, 10)])
# [(1, 0), (1, 0), (1, 0), (1, 1), (3, 2)]
print(fenceposts(3, "0%", "25%"))
# (0, 1)

The last rule is the one to remember. If both values resolve to zero, the controller sets the unavailable budget to one. The API validation rejects a spec where both are written as zero, and the documentation says maxUnavailable cannot be 0 if maxSurge is 0, but a percentage that only rounds to zero passes validation. The controller then quietly allows one pod to be unavailable.

Worked example: three services at the book store

The store runs three small services on Kubernetes, all with the default strategy unless noted.

ServiceReplicasmaxSurgemaxUnavailableResolved surgeResolved unavailablePods during rolloutMinimum available
Catalogue search325%25%10up to 43
Order API1025%25%32up to 138
Help desk worker30%25%01 (forced)up to 32

Catalogue search is a surge-only rollout. With three replicas, 25% unavailable rounds down to zero, so the controller never removes an old pod until a new one is ready. That is safe for availability, but it needs room for a fourth pod. If the namespace has a ResourceQuota sized for exactly three pods, or the nodes have no spare capacity, the new pod stays Pending and the rollout does not move. After progressDeadlineSeconds, 600 seconds by default, the Deployment reports the Progressing condition as false with reason ProgressDeadlineExceeded. Kubernetes does not roll back automatically; the old pods keep serving and the new version is simply not deployed.

Order API behaves as most people imagine: up to three extra pods, and at least eight of the ten available at all times. Rounding happens here too, 2.5 becoming three and two, but at this size it rarely matters.

Help desk worker was configured with maxSurge: 0% because the team wanted to avoid running more than three workers at once, each holding a connection to a rate-limited partner system. They expected the rollout to replace pods one at a time with at most 25% of capacity missing. Both values resolve to zero, the controller forces one unavailable, and the service runs at two thirds of its capacity during each step: 33%, not 25%. For a worker sized for peak load, that is the difference between keeping up and building a backlog during every deploy.

Why the two roundings differ

The two directions are both conservative, each in its own way. Rounding maxUnavailable down means the controller never takes away more serving capacity than the percentage allows; if 25% of three is 0.75 pods, it does not take one. Rounding maxSurge up means the rollout can always make progress when there is room, because at least one extra pod is permitted even when the percentage is a fraction of a pod. Taken together, the controller prefers spending extra capacity over losing serving capacity.

That preference is sensible for a large service and surprising for a small one. The surprise is not that the rules are wrong but that the configuration stops describing the behaviour. A reviewer reading "25% / 25%" pictures a rollout that removes a quarter of the pods at a time. At three replicas, none are removed until replacements are ready. At four replicas, one is removed at a time, which is exactly a quarter. The same two numbers produce qualitatively different rollouts as the replica count crosses small thresholds, and autoscaled services cross them every day.

What to set instead

Prefer absolute numbers for small deployments. A percentage expresses a policy for a large, elastic service; for three replicas, it hides a decision that should be explicit.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: helpdesk-worker
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1     # say what the controller would do anyway
  progressDeadlineSeconds: 600

The result for the help desk worker is the same as before, but now the configuration says what happens, and a reviewer can ask whether running at two thirds of capacity is acceptable. If it is not, the honest options are to add a replica, so one unavailable pod is a smaller share, or to allow a surge and solve the partner connection limit some other way, such as a connection budget that new pods wait for.

For the catalogue search service, decide whether surge-only is intended. If it is, make sure the quota and the cluster have room for one extra pod per deployment rolling at the same time. If several small deployments roll together, as they often do after a shared base image update, their surge needs add up.

Tradeoffs

  • Surge needs capacity; unavailability costs capacity. Every rolling update spends one of the two. Rounding decides which one for small replica counts, so decide it yourself.
  • Percentages scale with autoscaling. For deployments managed by a HorizontalPodAutoscaler, percentages keep the rollout proportionate as replica counts change. That is a good reason to use them, but check the behaviour at the minimum replica count, which is where rounding bites.
  • Readiness defines unavailable. The controller counts a pod as available when it has been ready for minReadySeconds. A readiness probe that passes before the service can actually handle load makes any maxUnavailable value optimistic.

Failure modes to check for

  • Stuck rollouts in tight namespaces. Surge-only rollouts plus exact quotas produce Pending pods and a deadline exceeded condition, often noticed only when someone asks why the new version is not live.
  • More disruption than configured. A maxSurge of zero with a percentage maxUnavailable that rounds to zero gives one unavailable pod, which is a large share of a small deployment.
  • Disruption budgets are a separate mechanism. A PodDisruptionBudget limits voluntary evictions, such as node drains, but the deployment controller does not consult it when scaling down old ReplicaSets during a rolling update. The two settings need to be planned together, not assumed to enforce each other.

Verification

Before changing a strategy, compute the resolved values for the current replica count and the minimum the autoscaler allows. The function above, or a table like the one in this guide, is enough. During a rollout, kubectl rollout status deployment/<name> shows progress, and kubectl get deployment <name> -o yaml shows the Progressing condition and its reason. After a rollout, check the maximum number of pods and the minimum number available from your metrics against what you computed. If they differ, something other than the strategy, such as readiness or quota, is shaping the rollout.

Primary references: the Kubernetes documentation for Deployments, sections on max unavailable and max surge, and ResolveFenceposts in the deployment controller utilities in the Kubernetes repository.

Primary references and authorship

Sources checked 2026-12-03. Original explanation and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/rolling_update_fenceposts. Views are my own and do not represent any employer, past or present.