Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
20210827 Future Tech Night
Search
Taisei Ito
August 27, 2021
Technology
0
4.4k
20210827 Future Tech Night
Taisei Ito
August 27, 2021
Tweet
Share
More Decks by Taisei Ito
See All by Taisei Ito
Grafana Meetup Japan Vol. 6
kaedemalu
1
410
Cloudflare Meetup Nagano Vol.3
kaedemalu
0
74
Cloudflare Meetup Nagano Vol.2
kaedemalu
0
1.6k
20220214_Future Tech Night
kaedemalu
0
2.3k
20210910_nyle
kaedemalu
0
980
CNDO2021 Open Policy Agent
kaedemalu
1
1.4k
20210210 Terraform meetup ONLINE
kaedemalu
0
660
Future Talk Night 20201118
kaedemalu
0
220
20201114 GCPUG Shonan
kaedemalu
0
450
Other Decks in Technology
See All in Technology
S3アクセス制御の設計ポイント
tommy0124
3
200
ブロックテーマ時代における、テーマの CSS について考える Toro_Unit / 2025.09.13 @ Shinshu WordPress Meetup
torounit
0
120
Snowflake Intelligenceにはこうやって立ち向かう!クラシルが考えるAI Readyなデータ基盤と活用のためのDataOps
gappy50
0
210
Terraformで構築する セルフサービス型データプラットフォーム / terraform-self-service-data-platform
pei0804
1
170
新アイテムをどう使っていくか?みんなであーだこーだ言ってみよう / 20250911-rpi-jam-tokyo
akkiesoft
0
260
allow_retry と Arel.sql / allow_retry and Arel.sql
euglena1215
1
170
2025年夏 コーディングエージェントを統べる者
nwiizo
0
160
AWSを利用する上で知っておきたい名前解決のはなし(10分版)
nagisa53
10
3.1k
COVESA VSSによる車両データモデルの標準化とAWS IoT FleetWiseの活用
osawa
1
280
自作JSエンジンに推しプロポーザルを実装したい!
sajikix
1
180
CDK CLIで使ってたあの機能、CDK Toolkit Libraryではどうやるの?
smt7174
4
170
生成AI時代のデータ基盤設計〜ペースレイヤリングで実現する高速開発と持続性〜 / Levtech Meetup_Session_2
sansan_randd
1
150
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Embracing the Ebb and Flow
colly
87
4.8k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Site-Speed That Sticks
csswizardry
10
810
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Building Adaptive Systems
keathley
43
2.7k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Unsuck your backbone
ammeep
671
58k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Transcript
21/8/27 Fri. Taisei Ito GCPのサーバーレスサービスを 利用したWebアプリ開発 Copyright © 2021 by
Future Corporation
Copyright © 2021 by Future Corporation 自己紹介 • 伊藤太斉(たいせい) @kaedemalu
◦ 2019年9月中途入社(社会人4年目) ◦ Technology Innovation Group所属 ◦ 技術ブログの中の人 • 技術領域 ◦ GCP, AWS, IaC(Terraform, Ansible) • コミュニティ ◦ GCPUG Shonan Staff ◦ CloudNative Days Committee
Agenda • 技術選定 • Serverless NEGの利用 • Serverless VPC Access
• ハマったポイント Copyright © 2021 by Future Corporation
概ねの方針 • 運用を楽に(≒管理コストをほぼ0にしたい) ◦ インフラの管理からの開放 ◦ リリースフローからの開放 • セキュリティはしっかり担保したい Copyright
© 2021 by Future Corporation
目指すゴール Copyright © 2021 by Future Corporation
はじめに 1 • 技術選定とアーキテクチャ
アーキテクチャ Copyright © 2021 by Future Corporation
利用サービスの選定 • コンテナですでに開発されている • リクエストが多くない • インフラの管理を極力減らしたい Copyright © 2021
by Future Corporation Compute Compute Engine Cloud Functions Container- Optimized OS Cloud Run Kubernetes Engine App Engine
利用サービスの選定 • コンテナですでに開発されている • リクエストが多くない • インフラの管理を極力減らしたい Copyright © 2021
by Future Corporation Compute Compute Engine Cloud Functions Container- Optimized OS Cloud Run Kubernetes Engine App Engine
利用サービスの選定 • コンテナですでに開発されている • リクエストが多くない • インフラの管理を極力減らしたい Copyright © 2021
by Future Corporation Compute Compute Engine Cloud Functions Container- Optimized OS Cloud Run Kubernetes Engine App Engine
利用サービスの選定 • コンテナですでに開発されている • リクエストが多くない • インフラの管理を極力減らしたい Copyright © 2021
by Future Corporation Compute Compute Engine Cloud Functions Container- Optimized OS Cloud Run Kubernetes Engine App Engine
利用サービスの選定 • コンテナですでに開発されている • リクエストが多くない • インフラの管理を極力減らしたい • アプリは3000ポートでリッスンしたい Copyright
© 2021 by Future Corporation Compute Compute Engine Cloud Functions Container- Optimized OS Cloud Run Kubernetes Engine App Engine
選ばれたのは、Cloud Runでした🎉 Copyright © 2021 by Future Corporation あと、新しいもの使いたいじゃない?
アーキテクチャ Copyright © 2021 by Future Corporation
Serverless NEGの活用 2
Serverless Network Endpoint Group(NEG) • 2020/10にGAになったサーバーレスサービス向けのNEG ◦ eg. App Engine,
Cloud Run, Cloud Functions • サーバーレスサービスを抽象化して、ロードバランサーと 組み合わせることを目的としている Copyright © 2021 by Future Corporation 参考:https://medium.com/google-cloud-jp/serverless-neg-でシステム開発をより柔軟に-4f9cebd2780f
実際に使う Copyright © 2021 by Future Corporation
Cloud Runを設定する • Cloud Runの実際に作成する ◦ コンテナが利用する環境変数 ◦ シークレット ◦
専用のサービスアカウント Copyright © 2021 by Future Corporation
GitOpsしよう • Cloud Runの画面からCloud Buildを作成する Copyright © 2021 by Future
Corporation
NEGの追加まで • 前ページで作成したCloud Run向けのNEGを作成する →LBのバックエンドサービスになる • HTTPSリクエストを受け付けるLBを作成する Copyright © 2021
by Future Corporation
サーバーレスVPCコネクタ 3
サーバーレスVPCコネクタ • サーバーレスサービスがVPCに直接接続するときに利用 ◦ Cloud RunやApp Engineが内部IP経由でアクセスできる (VPC内部のサービスを公開しなくても良い) • 他のVPCと接続(e.g.
VPC Peering)している場合も接続先の リソースまでアクセスできる Copyright © 2021 by Future Corporation 参考:https://cloud.google.com/vpc/docs/serverless-vpc-access?hl=ja
再)アーキテクチャ Copyright © 2021 by Future Corporation
実際に使う Copyright © 2021 by Future Corporation
作成する • /28のサブネットを作成する • サーバーレスVPCコネクタを作成する • コネクタで稼働するインスタンスのスペックを決定する Copyright © 2021
by Future Corporation 参考:https://cloud.google.com/vpc/docs/serverless-vpc-access?hl=ja
作成する Copyright © 2021 by Future Corporation 参考:https://cloud.google.com/vpc/docs/serverless-vpc-access?hl=ja
完成品(?) • 出来上がった!! Copyright © 2021 by Future Corporation
でもこれでは繋がらない Copyright © 2021 by Future Corporation
Shared VPC利用のハマり 4
サービスアカウントにハマる • Cloud Run作成時に「Cloud Runサービスエージェント」の ロールが付けられたサービスアカウントがこっそり作成される e.g.)
[email protected]
• ↑のサービスアカウントをShared
VPCのホストプロジェクトで 「サーバーレスVPCアクセスユーザー」を付与する Copyright © 2021 by Future Corporation 参考:https://cloud.google.com/run/docs/configuring/service-accounts?hl=ja
Cloud Runのエラー Cloud Run error: Container failed to start. Failed
to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information. Copyright © 2021 by Future Corporation 参考:https://cloud.google.com/run/docs/configuring/service-accounts?hl=ja • Runがポートをリッスンできない →あくまで「結果的に」リッスンできないだけ Cloud Loggingを見にいくと原因がしっかり出力されている
まとめ Copyright © 2021 by Future Corporation
完成品! Copyright © 2021 by Future Corporation
おわり Copyright © 2021 by Future Corporation