https://mercari.connpass.com/event/227024/ で発表しました。
アーカイブはYouTubeから見れます! https://www.youtube.com/watch?v=u5Eq-uJBvzg
ちなみに、TLA+チートシートは以下 https://zenn.dev/riita10069/articles/bc689cae1c7bc0
View Slide
GitHubAPI PRRCKubernetesDeploymentCreate/Update/Delete Virtual Service
Pros.Cons.
GitHubOpenClosekube-githuboperatorKubernetesDeploymentWebHookWebHookCreate/Update/DeleteVirtual ServicePull RequestRepositoryRepository PRRCCorrespond
How was it implemented?
https://hackernoon.com/level-triggering-and-reconciliation-in-kubernetes-1f17fe30333dLevelTriggeringArchitecture
Repository1Repository2Repository3GitHub WebHookmercari/Repository2/#12#12 #14#7 #11#68 #100 #100#65
Repository1Repository2Repository3GitHub WebHookmercari/Repository2/#12#12 #14#7 #11#68 #100 #100#65#12
Repository1Repository2Repository3GitHub WebHookmercari/Repository1/#12#12 #14#7 #11#68 #100 #100#65#12
Repository1Repository2Repository3GitHub WebHookmercari/Repository1/#12#12 #14#7 #11#68 #100 #100#65Updated!!#12
Repository1Repository2Repository3GitHub WebHookmercari/Repository3/#100#12 #14#7 #11#68 #100 #100#65#12
Repository1Repository2Repository3GitHub WebHookmercari/Repository3/#100#12 #14#7 #11#68 #100#65Updated!!Deleted!!#12
Repository1Repository2Repository3GitHub WebHookmercari/Repository4/#1#12 #14#7 #11#68 #100#65#12
Repository1Repository2Repository3GitHub WebHookmercari/Repository4/#1#12 #14#7 #11#68 #100#65#12Not Found!!
Is that really correct?
Distributed systems are difficult.
https://github.com/tlaplus/tlaplus
https://zenn.dev/riita10069/articles/bc689cae1c7bc0
#3 #3#1 #2GitHub WebHookmercari/Repository1/#3’Repository1GitHub WebHookmercari/Repository1/#3’’Updated!!#3’’#1 #2Repository1Updated!!#3’#1 #2Repository1
Assume that WebHooks for the same PR do not come instantly.
Verify the webhook is latest by timestamp
GitHubAPIKubernetesPull RequestCreate/Update/Deletekube-githuboperator
https://cloudark.medium.com/kubernetes-custom-controllers-b6c7d0668fdfInformer 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.
Create IndexCreate Key and ValueCall Lister with filter
https://github.com/kubernetes/client-go/blob/8aceb98010c1c18b6b54a35b52fd5b46905e3d7f/tools/cache/store.go#L68Key: Namespace/NameValue: Resource ObjectThere is no need to O(N) to find an object with a specific NamespacedName.
Controller API Server
ControllerClient Logic RepositoryAPI ServerKnows GitHubKnows APIKnows NothingSync Worker
Controller envtestDownload these binary directlyLogic RepositoryKnows envtestKnows Nothing
Logic RepositoryKnows Nothinghttps://github.com/sanposhiho/gomockhandlermock gomock gomockhandlerhttps://github.com/golang/mock
$ gomockhandler -config=/path/to/gomockhandler.json -source=foo.go -destination=./mock/Configuring a new mock$ gomockhandler mockgenGenerate mock$ gomockhandler checkVerify the mock is up to date
KubernetesWebHookkubectl