
How does the Kubernetes scheduler work? - tdurden
https://jvns.ca/blog/2017/07/27/how-does-the-kubernetes-scheduler-work/
======
smarterclayton
Generally the order of operations for someone writing a controller in Kube is:

1\. Do the basic loop with resync

2\. Fix a bunch of bugs

3\. Realize the controller is too slow (for all pods {} etc)

4\. Optimize for performance

5\. Soak for a few months

6\. Remove the resync interval

A correct controller will not need a resync interval. But it takes a while for
sufficient tests and soak time to prove the controller is correct, and the
resync is a great way to at least guarantee that state eventually converges.

For instance, 1.8 will remove the endpoint sync (after almost 2 years).
Endpoints were one of the first controllers, and kept on chugging along
without a problem. It's only now, with people running tens of thousands of
services, that the inefficiency of the controller is indicating a need to
optimize.

Controller loops are a great pattern because

1\. They embody the single-writer principle (you can get a lot of work done
single threaded at low scale and still reason about correctness)

2\. An inefficient loop that that continually makes sure everything is correct
is better in production than an efficient loop that breaks.

3\. Most of the efficient tooling is in place to adopt as we go.

