Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

GitHub API PRRC Kubernetes Deployment Create/Update/Delete Virtual Service

Slide 5

Slide 5 text

Pros. Cons.

Slide 6

Slide 6 text

GitHub Open Close kube-github operator Kubernetes Deployment WebHook WebHook Create/Update/Delete Virtual Service Pull Request Repository Repository PRRC Correspond

Slide 7

Slide 7 text

Pros. Cons.

Slide 8

Slide 8 text

How was it implemented?

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Repository1 Repository2 Repository3 GitHub WebHook mercari/Repository4/#1 #12 #14 #7 #11 #68 #100 #65 #12 Not Found!!

Slide 18

Slide 18 text

Is that really correct?

Slide 19

Slide 19 text

Distributed systems are dif f icult.

Slide 20

Slide 20 text

https://github.com/tlaplus/tlaplus

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

#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

Slide 25

Slide 25 text

Assume that WebHooks for the same PR do not come instantly.

Slide 26

Slide 26 text

Verify the webhook is latest by timestamp

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

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.

Slide 30

Slide 30 text

Create Index Create Key and Value Call Lister with filter

Slide 31

Slide 31 text

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.

Slide 32

Slide 32 text

Controller API Server

Slide 33

Slide 33 text

Controller Client Logic Repository API Server Knows GitHub Knows API Knows Nothing Sync Worker

Slide 34

Slide 34 text

Controller envtest Download these binary directly Logic Repository Knows envtest Knows Nothing

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

$ 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

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Kubernetes WebHook kubectl