Rule Resync and minSyncPeriod

A Pod has been deleted, yet for a short while kube-proxy rules can still send traffic to its old address. How long do those rules live on, what finally rewrites them, and what does the cluster gain by the wait?

Play the animation 6 steps, animated, plays on a computer or a tablet

Rule Resync and minSyncPeriod diagram: The kube-proxy sync loop drawn as a clock

Rule Resync and minSyncPeriod, step by step

  1. When a Pod dies, it reaches this loop only as a change to the EndpointSlice that listed the endpoint of that Pod. The change by itself rewrites nothing. It marks the rules stale and asks for a resync, and it is the resync that touches the kernel. How soon that resync runs is set by the floor between resyncs, not by the change itself.

    Play from step 1
  2. When the Deployment behind this Service is deleted, all 100 Pods of that Deployment go. The slice loses 100 ready endpoints, so 100 separate changes reach kube-proxy inside a very short window, and every one of them on its own is a reason to rewrite the rules in the kernel.

    Play from step 2
  3. With minSyncPeriod set to 0s kube-proxy resyncs immediately on every Service or EndpointSlice change. Those 100 deletions turn into 100 separate updates, and the endpoints are removed from the rules one at a time. That makes a great deal of redundant work whenever many things change in a short period.

    Play from step 3
  4. The floor is minSyncPeriod, and it is a floor rather than a delay. At the default 1s no resync starts sooner than a second after the previous one ends, so the changes waiting for it are aggregated. The same 100 deletions might fit into about 5 updates of 20 endpoints each. That is cheaper in CPU, and the full set of changes lands faster.

    Play from step 4
  5. The floor is paid for in stale rules. A change that arrives just after a resync waits for the next one, up to a full minSyncPeriod, and until then the rules still carry an endpoint the API server already shows not ready. A larger floor aggregates more work and widens that window.

    Play from step 5
  6. The other clock is syncPeriod, and it is not tied to any individual change. It paces the re-synchronizing and cleanup work no single change triggers: every syncPeriod kube-proxy checks whether an external component has interfered with its rules, and resyncs them if one has.

    Play from step 6

Sources