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

Kubernetes の API Client における
キャッシュ設計 / Cache Design in Kubernetes API Client

Kubernetes の API Client における
キャッシュ設計 / Cache Design in Kubernetes API Client

Go Conference 2019 Spring

93fd1aae13b44f9b0748bb3e60898da7?s=128

Takayuki Kasai

May 18, 2019
Tweet

Transcript

  1. ©2019 Wantedly, Inc. Kubernetes ͷ API Client ʹ͓͚Δ
 Ωϟογϡઃܭ Go

    Conference 2019 Spring Takayuki Kasai (@unblee) Wantedly, Inc. 2019.5.18 -
  2. ©2019 Wantedly, Inc. !VOCMFF5BLBZVLJ,BTBJ *OGSBTUSVDUVSF&OHJOFFS 8BOUFEMZ *OD ৽ଔ೥໨

  3. ©2019 Wantedly, Inc. w (PQIFST$PEF3FBEJOH1BSUZʢࣾ಺ษڧձʣͰͷίʔυϦʔσΟϯά w αʔϏεج൫ͱͯ͠,VCFSOFUFTΛ࢖༻͍ͯ͠Δ ςʔϚઃఆͷಈػ

  4. ©2019 Wantedly, Inc. w ,VCFSOFUFTͷΞʔΩςΫνϟͷಛ௃ w ΞʔΩςΫνϟʹଇͬͨ"1*ϦΫΤετΛ࡟ݮ͢ΔͨΊͷΩϟογϡઃܭ ࠓ೔࿩͢͜ͱ

  5. ©2019 Wantedly, Inc. w ίϯςφӡ༻ΛࣗಈԽ͢ΔͨΊͷϓϥοτϑΥʔϜ w σϓϩΠɺΦʔτεέʔϧɺࣗݾճ෮ɺϦιʔε࠷దԽɺFUD w ෳ਺ͷখ͍͞αʔϏε͕ڠௐಈ࡞ͯ͠ػೳΛ࣮ݱ͍ͯ͠Δ෼ࢄγεςϜ ,VCFSOFUFTͱ͸

    IUUQTLVCFSOFUFTJP
  6. ©2019 Wantedly, Inc. /PEF /PEF ,VCFSOFUFTͷΞʔΩςΫνϟ .BTUFS

  7. ©2019 Wantedly, Inc. /PEF $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS /PEF

    $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS ,VCFSOFUFTͷΞʔΩςΫνϟ .BTUFS "1*4FSWFS 4UBUF4UPSF
  8. ©2019 Wantedly, Inc. /PEF $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS /PEF

    $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS ,VCFSOFUFTͷΞʔΩςΫνϟ .BTUFS "1*4FSWFS 4UBUF4UPSF $POUSPMMFS $POUSPMMFS 3FTPVSDFͷঢ়ଶΛ࣮؀ڥ্ʹ൓өͤ͞Δ 3FTPVSDFૢ࡞ର৅Λந৅Խͨ֓͠೦ ίϯςφɺϩʔυόϥϯαɺFUD
  9. ©2019 Wantedly, Inc. /PEF $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS /PEF

    $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS ,VCFSOFUFTͷΞʔΩςΫνϟ .BTUFS "1*4FSWFS 4UBUF4UPSF "1*4FSWFS 3FTPVSDFΛૢ࡞͢ΔͨΊͷ"1*&OEQPJOUΛఏڙ͢Δ 3FTPVSDFͷมߋΠϕϯτΛ௨஌͢ΔͨΊͷ8BUDI"1*΋ఏڙ͍ͯ͠Δ
  10. ©2019 Wantedly, Inc. /PEF $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS /PEF

    $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS ,VCFSOFUFTͷΞʔΩςΫνϟ .BTUFS "1*4FSWFS 4UBUF4UPSF 4UBUF4UPSF 3FTPVSDFͷঢ়ଶ΍ઃఆɺൿಗ৘ใͱ͍ͬͨ ,VCFSOFUFTΛߏ੒͢ΔͨΊͷσʔλ͕อଘ͞Ε͍ͯΔ
  11. ©2019 Wantedly, Inc. /PEF $POUBJOFS $POUSPMMFS $POUBJOFS $POUBJOFS $POUBJOFS /PEF

    $POUBJOFS $POUSPMMFS $POUBJOFS $POUB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 w 3FTPVSDFͱ$POUSPMMFS͸/ͷؔ܎ w ͭͷ3FTPVSDF0CKFDUΛૢ࡞͢Δ͚ͩͰෳ਺ͷ$POUSPMMFS͕ಈ࡞͢Δ w "1*ϦΫΤετ͕େྔʹൃߦ͞ΕΔ
  14. ©2019 Wantedly, Inc. େྔͷ"1*ϦΫΤετʹΑΔ໰୊ ύϑΥʔϚϯεվળͷͨΊʹ࣮૷͞Εͨ΋ͷ w 3FGIUUQTLVCFSOFUFTJPCMPHLVCFSOFUFTQFSGPSNBODF NFBTVSFNFOUTBOE w "1*4FSWFSʹ8BUDI"1*ͱΩϟογϡػೳΛ࣮૷ͨ͠

    w 8BUDI"1*ϕʔεͰಈ࡞͢ΔΑ͏ʹ$POUSPMMFSΛॻ͖׵͑ͨ w ෛՙʹΑͬͯ"1*&OEQPJOUͷϨεϙϯελΠϜ͕௕͘ͳΔ w ͢΂͕ͯ"1*ʹΑ੍ͬͯޚ͞Ε͍ͯΔͷͰɺશମతͳಈ࡞͕ॏ͘ͳΔ
  15. ©2019 Wantedly, Inc. $POUSPMMFSʹ͓͚ΔΩϟογϡઃܭͷ֓ཁ "1*4FSWFS *OGPSNFS -JTU 8BUDI FWFOUT 1PQBPCKFDUGSPNRVFVF

    "EEUIFPCKFDU /PUJGZFWFOU $IBOHFUIFTUBUFPGUIFPCKFDU (FUUIFPCKFDUGSPNDBDIFTUPSF DMJFOUHP 6TFS )BOEMFS $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶈ ᶃ ᶄ ᶅ ᶆ ᶇ ,VCFSOFUFT"1*$MJFOU1BDLBHFҎԼʹΩϟογϡػߏ͕ఏڙ͞Ε͍ͯΔ IUUQTHPEPDPSHLTJPDMJFOUHPUPPMTDBDIF w $POUSPMMFSͰར༻͞Ε͍ͯΔ w 8BUDI"1*ΛલఏʹΩϟογϡػߏΛߏங͍ͯ͠Δ w ىಈ࣌ʹ͢΂ͯͷΦϒδΣΫτΛΩ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UT 1PQBPCKFDUGSPNRVFVF

    "EEUIFPCKFDU /PUJGZFWFOU $IBOHFUIFTUBUFPGUIFPCKFDU (FUUIFPCKFDUGSPNDBDIFTUPSF DMJFOUHP 6TFS )BOEMFS $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶈ ᶃ ᶄ ᶅ ᶆ ᶇ "1*4FSWFS (FUBMMUBSHFUSFTPVSDFPCKFDUT $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶃ EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ ᶄ $BDIFBMMPCKFDUT %FQMPZNFOU 3FQMJDB4FU 1PE %FQMPZNFOU 3FQMJDB4FU 1PE type Deployment struct { metav1.TypeMeta metav1.ObjectMeta Spec DeploymentSpec Status DeploymentStatus } IUUQTHPEPDPSHLTJPBQJBQQTW%FQMPZNFOU
  21. ©2019 Wantedly, Inc. EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ "1*4FSWFS *OGPSNFS -JTU 8BUDI FWFOUT 1PQBPCKFDUGSPNRVFVF

    "EEUIFPCKFDU /PUJGZFWFOU $IBOHFUIFTUBUFPGUIFPCKFDU (FUUIFPCKFDUGSPNDBDIFTUPSF DMJFOUHP 6TFS )BOEMFS $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶈ ᶃ ᶄ ᶅ ᶆ ᶇ "1*4FSWFS (FUBMMUBSHFUSFTPVSDFPCKFDUT $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶃ EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ ᶄ $BDIFBMMPCKFDUT %FQMPZNFOU 3FQMJDB4FU 1PE %FQMPZNFOU 3FQMJDB4FU 1PE type Lister interface { List(options metav1.ListOptions) (runtime.Object, error) } type Watcher interface { Watch(options metav1.ListOptions) (watch.Interface, error) } type ListerWatcher interface { Lister Watcher } IUUQTHPEPDPSHLTJPDMJFOUHPUPPMTDBDIF-JTUFS8BUDIFS IUUQTHPEPDPSHLTJPDMJFOUHPUPPMTDBDIF-JTUFS IUUQTHPEPDPSHLTJPDMJFOUHPUPPMTDBDIF8BUDIFS
  22. ©2019 Wantedly, Inc. EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ "1*4FSWFS *OGPSNFS -JTU 8BUDI FWFOUT 1PQBPCKFDUGSPNRVFVF

    "EEUIFPCKFDU /PUJGZFWFOU $IBOHFUIFTUBUFPGUIFPCKFDU (FUUIFPCKFDUGSPNDBDIFTUPSF DMJFOUHP 6TFS )BOEMFS $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶈ ᶃ ᶄ ᶅ ᶆ ᶇ EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } return client.AppsV1().Deployments(namespace).List(options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } return client.AppsV1().Deployments(namespace).Watch(options) }, }, &appsv1.Deployment{}, resyncPeriod, indexers, ) IUUQTHJUIVCDPNLVCFSOFUFTDMJFOUHPCMPCCEGCFDCCF⒎EDDBJOGPSNFSTBQQTWEFQMPZNFOUHP--
  23. ©2019 Wantedly, Inc. EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ "1*4FSWFS *OGPSNFS 8BUDIUBSHFUSFTPVSDFFWFOUT 1PQBPCKFDUGSPNRVFVF "EEUIFPCKFDU /PUJGZFWFOU

    $IBOHFUIFTUBUFPGUIFPCKFDU (FUUIFPCKFDUGSPNDBDIFTUPSF DMJFOUHP 6TFS )BOEMFS $BDIF4UPSF 0CKFDU 0CKFD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0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶈ ᶃ ᶄ ᶅ ᶆ ᶇ %FQMPZNFOU 3FQMJDB4FU 1PE %FQMPZNFOU 3FQMJDB4FU 1PE EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ 3FqFDUPS 2VFVF *OGPSNFS͕3FqFDUPS͕ड͚औͬͨΦϒδΣΫτΛΩϟογϡʹ௥Ճ͢Δ *OGPSNFS 1PQBPCKFDUGSPNRVFVF "EEUIFPCKFDU $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ ᶄ ᶅ %FQMPZNFOU 3FQMJDB4FU 1PE
  26. ©2019 Wantedly, Inc. EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ "1*4FSWFS *OGPSNFS 8BUDIUBSHFUSFTPVSDFFWFOUT 1PQBPCKFDUGSPNRVFVF "EEUIFPCKFDU /PUJGZFWFOU

    $IBOHFUIFTUBUFPGUIFPCKFDU (FUUIFPCKFDUGSPNDBDIFTUPSF DMJFOUHP 6TFS )BOEMFS $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶈ ᶃ ᶄ ᶅ ᶆ ᶇ %FQMPZNFOU 3FQMJDB4FU 1PE %FQMPZNFOU 3FQMJDB4FU 1PE EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ %FQMPZNFOU 3FQMJDB4FU 1PE type ThreadSafeStore interface type threadSafeMap struct { items map[string]interface{} } IUUQTHPEPDPSHLTJPDMJFOUHPUPPMTDBDIF5ISFBE4BGF4UPSF
  27. ©2019 Wantedly, Inc. EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ "1*4FSWFS *OGPSNFS 8BUDIUBSHFUSFTPVSDFFWFOUT 1PQBPCKFDUGSPNRVFVF "EEUIFPCKFDU /PUJGZFWFOU

    $IBOHFUIFTU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U 1PE (FUUIFPCKFDUGSPNDBDIFTUPSF ᶇ
  29. ©2019 Wantedly, Inc. EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ "1*4FSWFS *OGPSNFS 8BUDIUBSHFUSFTPVSDFFWFOUT 1PQBPCKFDUGSPNRVFVF "EEUIFPCKFDU /PUJGZFWFOU

    $IBOHFUIFTUBUFPGUIFPCKFDU (FUUIFPCKFDUGSPNDBDIFTUPSF DMJFOUHP 6TFS )BOEMFS $BDIF4UPSF 0CKFDU 0CKFDU 0CKFDU/ 3FqFDUPS 2VFVF ᶈ ᶃ ᶄ ᶅ ᶆ ᶇ %FQMPZNFOU 3FQMJDB4FU 1PE %FQMPZNFOU 3FQMJDB4FU 1PE EFQMPZNFOUDPOUSPMMFSʹ͓͚ΔΩϟογϡར༻ func (dc *DeploymentController) syncDeployment(key string) error { namespace, name, err := cache.SplitMetaNamespaceKey(key) deployment, err := dc.dLister.Deployments(namespace).Get(name) d := deployment.DeepCopy() if reflect.DeepEqual(d.Spec.Selector, &everything) { dc.eventRecorder.Eventf(d, v1.EventTypeWarning, "SelectingAll", "This deployment is selecting all pods. A non- empty selector is required.") if d.Status.ObservedGeneration < d.Generation { d.Status.ObservedGeneration = d.Generation dc.client.AppsV1().Deployments(d.Namespace).UpdateStatus(d) } return nil } rsList, err := dc.getReplicaSetsForDeployment(d) podMap, err := dc.getPodMapForDeployment(d, rsList) if getRollbackTo(d) != nil { return dc.rollback(d, rsList) } scalingEvent, err := dc.isScalingEvent(d, rsList) switch d.Spec.Strategy.Type { case apps.RecreateDeploymentStrategyType: return dc.rolloutRecreate(d, rsList, podMap) case apps.RollingUpdateDeploymentStrategyType: return dc.rolloutRolling(d, rsList) } } IUUQTHJUIVCDPNLVCFSOFUFTLVCFSOFUFTCMPCBGGFFCFFCGBFFGFDQLHDPOUSPMMFSEFQMPZNFOUEFQMPZNFOU@DPOUSPMMFSHP--
  30. ©2019 Wantedly, Inc. EFQMPZNFOUDPOUSP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࡟ݮʹ༗ޮ w ,VCFSOFUFTͷΑ͏ͳେن໛044Ͱ΋ݸʑͷύοέʔδΛಡΜͰΈΔͱ໘ന͍

    ·ͱΊ
  33. ©2019 Wantedly, Inc. એ఻ ຖि݄༵೔.JDSPTFSWJDFT.POEBZ IUUQTXXXXBOUFEMZDPNQSPKFDUT IUUQTHJUIVCDPNXBOUFEMZNJDSPTFSWJDFT@NPOEBZ ຖिਫ༵೔(PQIFST$PEF3FBEJOH1BSUZ IUUQTHJUIVCDPNXBOUFEMZHPQIFSTDPEFSFBEJOHQBSUZJTTVFT ؾʹͳΔਓ͸੠Λ͔͚͍ͯͩ͘͞