Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kubernetes Controllers - are they loops or events?

Tim Hockin
February 20, 2021

Kubernetes Controllers - are they loops or events?

Tim Hockin

February 20, 2021
Tweet

More Decks by Tim Hockin

Other Decks in Technology

Transcript

  1. Imagine a controller for Pods (aka kubelet). It has 2

    jobs: 1) Actuate the pod API 2) Report status on pods
  2. Node Kubernetes API a kubelet b c { name: a,

    ... } { name: b, ... } { name: c, ... }
  3. Node Kubernetes API a kubelet b c for each pod

    p { if p is running { verify p config } else { start p } gather status }
  4. Node Kubernetes API a kubelet c I have “b” but

    API doesn’t - delete it! c a b
  5. We could poll less often, but then it takes a

    long (and variable) time to react - not a great UX
  6. Node Kubernetes API a kubelet b c { name: a,

    ... } { name: b, ... } { name: c, ... }
  7. Node Kubernetes API a kubelet b c Cache: { name:

    a, ... } { name: b, ... } { name: c, ... }
  8. Node Kubernetes API a kubelet b c Watch all pods

    Cache: { name: a, ... } { name: b, ... } { name: c, ... }
  9. Node Kubernetes API a kubelet b c Cache: { name:

    a, ... } { name: b, ... } { name: c, ... } for each pod p { if p is running { verify p config } else { start p } gather status }
  10. Node Kubernetes API a kubelet b c Set status c

    a b Cache: { name: a, ... } { name: b, ... } { name: c, ... }
  11. Node Kubernetes API a kubelet b c c a b

    kubectl delete pod b Cache: { name: a, ... } { name: b, ... } { name: c, ... }
  12. Node Kubernetes API a kubelet c c a b kubectl

    delete pod b Cache: { name: a, ... } { name: b, ... } { name: c, ... }
  13. Node Kubernetes API a kubelet c Delete: { name: b,

    ... } c a b Cache: { name: a, ... } { name: b, ... } { name: c, ... }
  14. Node Kubernetes API a kubelet c Delete: { name: b,

    ... } c a b Cache: { name: a, ... } { name: c, ... }
  15. Node Kubernetes API a kubelet c Cache: { name: a,

    ... } { name: c, ... } c a b API said to delete pod “b”.
  16. Node Kubernetes API a kubelet c Cache: { name: a,

    ... } { name: c, ... } c a API said to delete pod “b”.
  17. The controller can be restarted at any time and the

    cache will be reconstructed - we can’t “miss an edge*” * modulo bugs, read on
  18. Ultimately it’s all just software, and software has bugs. Controllers

    should re-list periodically to get full state...
  19. ...but we’ve put a lot of energy into making sure

    that our list-watch is reliable.