ããã«ã¡ã¯ã Backend Engineer ã® @vkgtaro ã§ãã
ã¡ã«ã«ãªã§ã¯ä»ã¾ã§ PHP ã§éçºãããã¢ããªã·ãã¯ãª API ã«å¯¾ãã¦æ©è½ã追å ãã¦ããã®ã§ãããä»å¾ã¡ã«ã«ãªã®ã·ã¹ãã ã Microservices åãã¦ãããã®å é§ãã¨ãã¦ãOffer ã¨ããæ°æ©è½ã Microservices Platform ä¸ã§éçºã»ãªãªã¼ã¹ãã¾ãããOffer ã¯ä»ã¾ã§ã³ã¡ã³ãæ¬ã§ãªããã¦ããå¤ä¸ãè¦æ±ãæ©è½ã¨ãã¦ã§ããããã«ãããã®ã§ãåºåè ããæ¿è«¾ãå¾ãããã° Offer ããéé¡ã§è³¼å ¥ã§ããã¨ãããã®ã§ããåãåã£ã人ã¯ãã¡ããæããã¨ãã§ãã¾ãã
2018/07/10 ç¾å¨ããã¤ã³ããªã¢ã»ä½ã¾ãã»å°ç©ãã«ãã´ãªã¼ã«ã¦ä½¿ç¨å¯è½ã«ãªã£ã¦ãã¾ãã
ä»åã¯ãã®æ©è½ãå®è£ ããã«ããã£ã¦ãã£ããã¨ãããããæ¯ãè¿ã£ã¦ã¿ããã¨æãã¾ãã
ãã£ããå ¨ä½åã¯ãããªæãã«ãªã£ã¦ã¾ãã
端æ«ã¨ã¤ãªããã¯ããã¦ã®ãµã¼ãã¹
ããã¾ã§ã«ãã¡ã«ã«ãª API ããç¬ç«ãããµã¼ãã¹ã¯ããã¤ããã£ãã®ã§ããã API Gateway ããç´æ¥ã¶ãä¸ãã£ã¦ãããµã¼ãã¹ã¨ãã¦ã¯ä»åã® Offer ãã¯ããã¦ã®ãµã¼ãã¹ã¨ãªãã¾ãã
API Gateway ã«ã¤ãã¦ã¯å
æ¥ã® mercari.go ã®è³æãåç
§ãã¦ãã ããã
Offer 㨠API Gateway é㯠gRPC ã§æ¥ç¶ããã¦ããã API Gateway 㨠iOS / Android é㯠Protocol Buffers ã HTTP ã§éä¿¡ããããã«ãªã£ã¦ãã¾ãã
iOS / Android ãã /services/hoge/v1/echo
㸠Protocol Buffers ã§ã·ãªã¢ã©ã¤ãºãããã¼ã¿ããªã¯ã¨ã¹ããã㨠API Gataway ãéãã¦ãgRPC 㧠EchoRequest ãå¼ã³åºãããã¨ããå
·åã§ãã
API Gateway å´ã®è¨å®
"/services/hoge/v1/echo": &gateway.GRPCMethod{ Name: "Echo", RequestMessage: &hoge_pb.HogeEchoRequest{}, ResponseMessage: &hoge_pb.HogeEchoResponse{}, },
Interface 㯠proto ãã¡ã¤ã«ã§ç®¡ç
Protocol Buffers ãªã®ã§ proto ãã¡ã¤ã«ãç¨ãã¦ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®ç®¡çããã¦ãã¾ãã
proto ãã¡ã¤ã«ã¯ä¸ã¤ã® GitHub ãªãã¸ããªä¸ã§ç®¡çãã¦ãã¦ãä»ã®ãµã¼ãã¹ã®ãã®ãä¸å
管çããã¦ãã¾ãã
proto ãã¡ã¤ã«ç¨ã®ãªãã¸ããªã« PR ãä½æããpush ããããå種è¨èªã® protbuf ã¢ã¸ã¥ã¼ã«ãçæãããä»çµã¿ã«ãªã£ã¦ãã¾ãã
Offer ã§ã¯ golang, PHP ã®ã¢ã¸ã¥ã¼ã«ãããã§çæãã¦ä½¿ç¨ãã¦ãã¾ããã Java, Swift ã¯éçºä¸ã¯ä»çµã¿ãéã«åã£ã¦ããªãã£ãã®ã§ããããã¨ã¯åã proto ãã¡ã¤ã«ããã¨ã«ä½ã£ã¦ãã¾ãã
ããã«ããã¯ã©ã¤ã¢ã³ãã¨ããã¯ã¨ã³ãã®éçºæã®è©±ãåã㯠proto ãã¡ã¤ã«ããã¨ã«ä¼è©±ãã§ãã¾ããã
ã¾ããã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯ãã¼ã¸ã§ã³ãåºåã£ã¦ä½ã£ã¦ãããå°æ¥å¤§ããªå¤æ´ãå ¥ãå ´åã«ã¯ v1 ã v2 ã«ãã¦è¡ãäºå®ã§ãã
platform-proto/proto/offer-jp/v1/offer.proto
deploy
development / production ç°å¢ã¸ã® deploy ã«ã¤ãã¦ã¯ã Spinnaker ã使ã£ã¦ãããã¤ãã¦ãã¾ããï¼SpinnakerによるContinuous Delivery – Mercari Engineering Blogï¼
GitHub 㧠stage/development ã¸ãã¼ã¸ãã㨠Circle CI ã docker image ãä½ã£ã¦ GCR ã¸ããã·ã¥ããã®ã§ã Spinnaker å´ã§ã¯ã GCR ã trigger ã«ãã PIPELINE ãç¨æãã¦ããã¦ãã®ã¾ã¾ Spinnaker ã deploy ããããã«ãã¦ãã¾ãã
Offer 㯠CloudSQL ã使ã£ã¦ãã¦ããã¤ã°ã¬ã¼ã·ã§ã³ãã¼ã«ä½ã£ã¦ããã®ã§ Spinnaker ãéãã¦å®è¡ãã¦ãã¾ãã
Pod ã®æ§æ
Spinnaker ã§ãããã¤ãããã®ã¯æ¬¡ã®ãããªæ§æã® Pod ã§ãã
CloudSQL ã使ã£ã¦ããã®ã§ CloudSQL Proxy ãè¼ãããµã¤ãã«ã¼ãã¿ã¼ã³ã® Pod ããããã¤ãã¦ãã¾ãã
ã¤ã³ãã©ã®ã³ã³ããã¼ã«ã¯ Terraform
Microservice ã¯éçºè
ãèªåãã¡ã§ã¤ã³ãã©ãããç¨åº¦ã³ã³ããã¼ã«ãããã§ããã GCP ã®ã³ã³ã½ã¼ã«ã§ç´æ¥æ±ããããªãã¨ã¯ããã« Terraform 使ã£ã¦ã³ã³ããã¼ã«ãã¦ãã¾ãã
Terraform ã Microservice Platform ãã¼ã ã«ãã£ã¦ãªãã¸ããªãç¨æããã¦ãããPR ãä½ã£ã¦ãã¼ã¸ãã¦ãããã¨èªåã§é©ç¨ãããããã«ãªã£ã¦ãã¾ãã
ã¾ããGCP ã«éãã PagerDuty ã DataDog ãªã©é¢é£ãµã¼ãã¹ã®ã³ã³ããã¼ã«ã Terraform ã§è¡ã£ã¦ãã¾ãã
メルカリ Microservices Team による Terraform 運用とその中で開発したOSSの紹介 – Mercari Engineering Blog
Terraform ã®ãªãã¸ããªã¯åãã¼ã ã®è¨å®ãå¯è¦åããã¦ãã¦ãããã®ãµã¼ãã¹ã® CloudSQL ã®ã¤ã³ã¹ã¿ã³ã¹ãµã¤ãºã¯ã©ã®ããããªãã ããåèã«ããããã¨ãè¡ã£ãã¨ãã« grep ãã¦æ¢ããã®ãããã§ãããã®ã¾ã¾ãã¬ãã¸ã¨ãã¦éç©ããã¦ãã¾ãã
ã«ã¹ã¿ãã¼ãµãã¼ã管çãã¼ã«ã¸ã®ã¤ãªãè¾¼ã¿
æ°ãã«ãªã«ãä½ãã¨å¿
ãããã®ã CSTool ã¨å¼ã°ããã«ã¹ã¿ãã¼ãµãã¼ãç¨ã®ç®¡çç»é¢ã§ããã客ãã¾ããã®ãåãåããã«å¯¾ãããªãã¡ã¼ãããç¶æ
ãªã©ã確èªã§ããããã«ãããããCSTool ã¸ã®ã¤ãªããã¿ãè¡ãã¾ããã
CSTool ããã®ã¤ãªããã¿ã¯ãç´æ¥ gRPC ã§å Microservice ã¸ã¤ãªããããã¨ãã話ãããã¾ããããGCP ã® Service Account ãç¨æãã¦ãAPI Gateway ãéãã¦æ¥ç¶ãããã¨ãããã¨ã«ãªãã¾ããã
Google ã® OAuth ãéã㦠JWT ãã¼ã¯ã³ãåå¾ãã¦ãAuthentication ãããã«å«ãã¦ã¢ã¯ã»ã¹ãããã¨ã§ãã©ã® service account ããæ¥ã¦ããã®ããå¤æãã¦ãã¾ãã
ã¾ã¨ã
ã¡ã«ã«ãªã§ã® Microservice Platform ä¸ã§ã®éçºã«ã¤ãã¦åºãæµ ãç´¹ä»ãã¦ã¿ã¾ãããå°ãã§ãã¡ã«ã«ãªã® Microservice Platform ã«ã¤ãã¦ä¼ããã°å¹¸ãã§ããä»å¾ã¯ä»ããã¢ããªã·ãã¯ãª API ã Microservice ã«åå²ãã¦ãããéçºè ãèªåã®ä»äºã«å°å¿µã§ããç¶æ³ãä½ã£ã¦ããã¾ãã
ããã¦ãæ¥éãªé²åãéããããã«ããã£ã¨æ²¢å±±ã®ä»²éãå¿ è¦ã¨ãã¦ãã¾ãï¼ ãèå³ã®ããæ¹ã¯ãã²ãé£çµ¡ãã ããï¼
Backend Engineer Drink Meetup #1
ã¾ãã2018/07/17(ç«) 19:00 ã ããã¯ã¨ã³ãã¨ã³ã¸ãã¢ã® Drink meetup ããã¾ãï¼
ãã®è¨äºã§ç´¹ä»ãããã¨ã話ãäºå®ã§ãã詳ããèãã¦ã¿ããã¨ããæ¹ã¯ãã²ãã¨ã³ããªã¼ãé¡ããã¾ãï¼