Save 37% off PRO during our Black Friday Sale! »

Pull Request Replication Controller

Abde1cc59b4baaec3c12d65581c5d017?s=47 riita10069
October 21, 2021

Pull Request Replication Controller

https://mercari.connpass.com/event/227024/
で発表しました。

アーカイブはYouTubeから見れます!
https://www.youtube.com/watch?v=u5Eq-uJBvzg

ちなみに、TLA+チートシートは以下
https://zenn.dev/riita10069/articles/bc689cae1c7bc0

Abde1cc59b4baaec3c12d65581c5d017?s=128

riita10069

October 21, 2021
Tweet

Transcript

  1. None
  2. None
  3. None
  4. GitHub API PRRC Kubernetes Deployment Create/Update/Delete Virtual Service

  5. Pros. Cons.

  6. GitHub Open Close kube-github operator Kubernetes Deployment WebHook WebHook Create/Update/Delete

    Virtual Service Pull Request Repository Repository PRRC Correspond
  7. Pros. Cons.

  8. How was it implemented?

  9. https://hackernoon.com/level-triggering-and-reconciliation-in-kubernetes-1f17fe30333d Level Triggering Architecture

  10. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository2/#12 #12 #14 #7 #11

    #68 #100 #100 #65
  11. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository2/#12 #12 #14 #7 #11

    #68 #100 #100 #65 #12
  12. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository1/#12 #12 #14 #7 #11

    #68 #100 #100 #65 #12
  13. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository1/#12 #12 #14 #7 #11

    #68 #100 #100 #65 Updated!! #12
  14. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository3/#100 #12 #14 #7 #11

    #68 #100 #100 #65 #12
  15. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository3/#100 #12 #14 #7 #11

    #68 #100 #65 Updated!! Deleted!! #12
  16. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository4/#1 #12 #14 #7 #11

    #68 #100 #65 #12
  17. Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository4/#1 #12 #14 #7 #11

    #68 #100 #65 #12 Not Found!!
  18. Is that really correct?

  19. Distributed systems are dif f icult.

  20. https://github.com/tlaplus/tlaplus

  21. https://zenn.dev/riita10069/articles/bc689cae1c7bc0

  22. None
  23. None
  24. #3 #3 #1 #2 GitHub WebHook mercari/Repository1/#3’ Repository1 GitHub WebHook

    mercari/Repository1/#3’’ Updated!! #3’’ #1 #2 Repository1 Updated!! #3’ #1 #2 Repository1
  25. Assume that WebHooks for the same PR do not come

    instantly.
  26. Verify the webhook is latest by timestamp

  27. GitHub API Kubernetes Pull Request Create/Update/Delete kube-github operator

  28. None
  29. https://cloudark.medium.com/kubernetes-custom-controllers-b6c7d0668fdf Informer is a component which monitors object changes 


    and stores data in a thread-safe in-memory cache. Lister is a component which gets list of resources.
  30. Create Index Create Key and Value Call Lister with filter

  31. https://github.com/kubernetes/client-go/blob/8aceb98010c1c18b6b54a35b52fd5b46905e3d7f/tools/cache/store.go#L68 Key: Namespace/Name Value: Resource Object There is no need

    to O(N) to find an object with a specific NamespacedName.
  32. Controller API Server

  33. Controller Client Logic Repository API Server Knows GitHub Knows API

    Knows Nothing Sync Worker
  34. Controller envtest Download these binary directly Logic Repository Knows envtest

    Knows Nothing
  35. Logic Repository Knows Nothing https://github.com/sanposhiho/gomockhandler mock gomock gomockhandler https://github.com/golang/mock

  36. $ gomockhandler -config=/path/to/gomockhandler.json -source=foo.go -destination=./mock/ Configuring a new mock $

    gomockhandler mockgen Generate mock $ gomockhandler check Verify the mock is up to date
  37. None
  38. Kubernetes WebHook kubectl