SlideShare a Scribd company logo
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
D E V D AY
N O V 9 , 2 0 2 2
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS上の
開発体験を最⼤化する
プレビュー環境の作り⽅
⼭﨑理弘(かたいなか)
C - 2
SRE
株式会社リブセンス
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⾃⼰紹介
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⾃⼰紹介
• ⼭﨑理弘(かたいなか)
• 株式会社リブセンス SRE
• コンテナ関連の技術が好き
• Twitter,GitHub: @katainaka0503
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アジェンダ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アジェンダ
• プレビュー環境とは
• プレビュー環境の構成要素
• Amazon EKS上での
ArgoCDとIstioを使った実装例
• プレビュー環境導⼊までのロードマップ
• まとめ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境とは
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
マイクロサービス開発での悩み
• 呼び出される側のマイクロサービスの動作確認が⼤変
§ 開発環境にデプロイするまで
他マイクロサービスと結合して動作確認できない
• 動作確認は後からになりPR Reviewの精度が低下
§ ローカルで動かして動作確認することもできるが、
⼤量のマイクロサービスをローカルで動かすのは⼤変
• バグ修正Pull Requestが頻発
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境とは
• Pull Request(以降PR)のブランチから作成されたコンテナイメージを
他のマイクロサービスと結合して動作確認できる環境
§ 既存の環境を壊したり占有したりしない
§ PR作成などのタイミングで⾃動で環境が作成される
§ PRごとに専⽤の特別なURLから動作確認できる
– 例: “pr-1.preview.example.com”
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
全体像
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションをPRごとにデプロイ
• PRからビルドしたイメージを、
開発環境と同様の設定でデプロイ
• PRがマージされたら⾃動で削除
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
クラスタの⼊り⼝でURLをヘッダに変換
• ヘッダ伝播で伝播させるため、
URLをヘッダに変換
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションによるヘッダ伝播
• 上流から受け取った情報を
他のサービス呼び出し時に
ヘッダで渡す
• どのPRのプレビュー環境への
アクセスかの情報を伝播
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ルーティングの設定をPRごとにデプロイ
• ヘッダ伝播で使うヘッダを元に
トラフィックを振り分ける設定を
PRごとにデプロイ
• PRがマージされたら削除
• プレビュー環境⽤の設定に
マッチしなければ、
既存の環境に流す設定も適⽤
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
まとめると
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS上での
Argo CDとIstioを使った実装例
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
実装に使⽤する技術
• Argo CD
• Istio
• Open Telemetry
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Argo CDとは
• KubernetesクラスタとGitHub等を同期するGitOpsを実現するツール
§ GitHub上のコードを変更したら変更がクラスタに同期
• Image Updaterによるイメージの更新も
• Application SetsによるPRごとのデプロイ機能
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Istioとは
• オープンソースのサービスメッシュの実装
§ サービス間の通信をインターセプトして様々な便利機能を提供
• 可観測性の向上
§ 分散トレーシング機能
• トラフィックの管理
§ L7/L4情報によるルーティング
• セキュリティの向上
§ mTLSによる通信の暗号化
§ ポリシーベースのアクセス制御
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Open Telemetryとは
• 分散トレーシングのベンダに依存しない規格および実装
• 様々な⾔語の主要なライブラリをカバーしたSDKを公式で提供
• AWS X-RayやDatadog APM等に結果を送信できる
• SDKがBaggageヘッダによるヘッダ伝播の仕組みを提供
§ BaggageはW3Cによるコンテキスト伝播のための規格
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素(おさらい)
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
全体像
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションをPRごとにデプロイ
• ArgoCDで右図を実現する
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションをPRごとにデプロイ
• Pull Request Generatorで
PRごとのデプロイを実現(①)
• Image Updaterで
ビルドされたイメージに
更新させる(②)
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: frontend-pr-env
namespace: argocd
spec:
generators:
- pullRequest:
github:
owner: katainaka0503
repo: grpc-pr-env-test-frontend
template:
metadata:
name: '{{branch}}-frontend’
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
annotations:
argocd-image-updater.argoproj.io/image-list: app=<image>
argocd-image-updater.argoproj.io/app.update-strategy: latest
argocd-image-updater.argoproj.io/app.allow-tags: regexp:{{branch}}-.*
argocd-image-updater.argoproj.io/write-back-method: git
spec:
project: default
source:
repoURL: <repo>
path: <kustomize path>
targetRevision: master
kustomize:
namePrefix: '{{branch}}-'
①
②
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
クラスタの⼊り⼝でURLをヘッダに変換
• Nginx等のアプリケーションで
URLをヘッダに変換
upstream frontend {
server frontend.default.svc.cluster.local:80;
}
server {
listen 80 http2;
# 正規表現でbaggageヘッダに使う値を取得
server_name ~^(?<branch>.+)¥.preview¥.example¥.com$;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
# baggageヘッダを設定
proxy_set_header baggage branch=${branch};
location / {
proxy_pass http://frontend;
}
}
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションによるヘッダ伝播
• OpenTelemetryにより
baggageヘッダが伝播
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションによるヘッダ伝播
// Bagggageによる伝播を有効化
otel.SetTextMapPropagator(propagation.Baggage{})
// InterceptorでOpenTelemetryを仕込む
s := grpc.NewServer(grpc.UnaryInterceptor(otelgrpc.UnaryServerInterceptor()),
grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor()))
pb.RegiterGreeterServer(s, &server{})
サ ー バ 側 の 実 装 ( G R P C )
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションによるヘッダ伝播
// Baggageを有効化
otel.SetTextMapPropagator(propagation.Baggage{})
// InterceptorでOpenTelemetryを仕込む
conn, err := grpc.Dial(*addr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()),
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()))
ク ラ イ ア ン ト 側 の 実 装 ( G R P C )
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境の構成要素
• アプリケーションをPRごとにデプロイ
• クラスタの⼊り⼝でURLをヘッダに変換
• アプリケーションによるヘッダ伝播
• ルーティングの設定をPRごとにデプロイ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ルーティングの設定をPRごとにデプロイ
• 右図をArgoCD + Istioで実現
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ルーティングの設定をPRごとにデプロイ
• Baggageヘッダを元に
ルーティング
• PRごとにデプロイした際に
優先順位で問題が⽣じない
Gateway APIを使⽤
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
name: {{ .Release.Name }}
spec:
parentRefs:
- kind: Mesh
name: istio
hostnames: ["{{ .Values.app }}.default.svc.cluster.local"]
rules:
- matches:
- headers:
- type: RegularExpression
name: baggage
value: ^(.*¥s*;)?branch¥s*=¥s*{{ .Values.branch }}(¥s*;.*)?$
backendRefs:
- name: {{ .Values.branch }}-{{ .Values.app }}
port: 80
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ルーティングの設定をPRごとにデプロイ
• Application Setで設定を複製
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: backend-pr-env-routing
namespace: argocd
spec:
generators:
- pullRequest:
github:
owner: katainaka0503
repo: grpc-pr-env-test-backend
template:
metadata:
name: '{{branch}}-backend-routing’
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: <repo URL>
path: <helm path>
targetRevision: master
helm:
releaseName: backend-{{ branch }}-pr
parameters:
- name: branch
value: '{{ branch }}’
- name: app
value: <app name>
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
まとめると
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
デモ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
実際の環境に適⽤するには
§ 実装上の制限
– Image Updaterが作成するファイルを定期的に消す
§ コスト⾯
– Preview環境のPodのCPU・メモリを最⼩限に
– GitOpsの⼒を借りて必要な部分だけPRごとにデプロイ
§ セキュリティ⾯
– レビューが通っていない差分のSQLが実⾏されるのでDBの権限を絞る
– プレビュー環境のURLで画像等が取得できるようCORSの設定変更
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プレビュー環境導入までの
ロードマップ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
現実
• ここまで紹介したような仕組みをいますぐ⼊れようと頑張るのが、
すべての組織にとってベストというわけではない
§ 構成要素が多いため
プレビュー環境のためだけに導⼊するのは⼤変
§ 構成要素が新しいのでキャッチアップコストがかかる
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⼀⽅で
• プレビュー環境の実装に使えるツールは
プレビュー環境が関係ない⽂脈でも便利
§ Argo CD
§ Istio
§ Open Telemetry
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
提案
• まずは運⽤負荷・導⼊コストが低いよりライトな仕組みを実現する
• 分散トレーシングやサービスメッシュをサービスの成⻑に合わせて
順番に導⼊する
§ 技術選定の基準にPreview環境の実現可能性も加える
• 仕組みが整い、開発⼈数も増え、ビジネスも成⻑したタイミングで
プレビュー環境を導⼊する
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
よりライトな仕組みの例
• PRマージ時のステージングデプロイ
• ブランチを指定してステージングにデプロイ
• フロントエンドだけプレビュー環境を⽤意
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
PRマージ時のステージングデプロイ
• ⼀般的なCI/CD
• 開発初期ではこれで充分な場合も多そう
• モノリスをごく少⼈数で開発しているケース等、
ローカルで動作確認できるならこれで⼗分な場合も
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ブランチを指定してステージングにデプロイ
• mainブランチではないブランチも指定して
デプロイできるようにする
• ステージングを⼀時的に占有して動作確認
• ステージングを占有するので開発⼈数が増えると待ちが発⽣する
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
フロントエンドにだけプレビュー環境を⽤意
• フロントエンドだけならヘッダ伝播のしくみは不要
§ モノリスの場合も同様の理由で不要な場合あり
• 重要なロジックが各マイクロサービスに移譲されるに従って
カバーできるケースが減る
• Amplify Hosting等既存サービスが使える場合も
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ロードマップのスケッチ例
• サービスが軌道に乗るまで
§ 最低限のCI/CD
• 運⽤改善に⼿を回せるようになったら
§ Open Telemetryで分散トレーシングを⼊れる
§ フロントだけのプレビュー環境を⽤意する
• 開発⼈員を増やして更に開発本格化するときには
§ マイクロサービス化 or BFFの導⼊に合わせて
ブランチデプロイを導⼊
• さらに開発⼈員やマイクロサービスの数が増えてきたら
§ Istioでプレビュー環境を⽤意
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
まとめ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
まとめ
• プレビュー環境の構成要素
§ アプリケーションのPRごとのデプロイ
§ URLをヘッダに変換
§ アプリケーションによるヘッダ伝播
§ ルーティングの設定のPRごとにデプロイ
• プレビュー環境を無理に急いで作ろうとせず、
サービスの成⻑に合わせて計画的に
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.

More Related Content

What's hot

実運用して分かったRabbit MQの良いところ・気をつけること #jjug
実運用して分かったRabbit MQの良いところ・気をつけること #jjug実運用して分かったRabbit MQの良いところ・気をつけること #jjug
実運用して分かったRabbit MQの良いところ・気をつけること #jjug
Yahoo!デベロッパーネットワーク
 
Amazon EKS によるスマホゲームのバックエンド運用事例
Amazon EKS によるスマホゲームのバックエンド運用事例Amazon EKS によるスマホゲームのバックエンド運用事例
Amazon EKS によるスマホゲームのバックエンド運用事例
gree_tech
 
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
NTT DATA Technology & Innovation
 
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
NTT DATA Technology & Innovation
 
分散トレーシング技術について(Open tracingやjaeger)
分散トレーシング技術について(Open tracingやjaeger)分散トレーシング技術について(Open tracingやjaeger)
分散トレーシング技術について(Open tracingやjaeger)
NTT Communications Technology Development
 
とにかく分かりづらいTwelve-Factor Appの解説を試みる
とにかく分かりづらいTwelve-Factor Appの解説を試みるとにかく分かりづらいTwelve-Factor Appの解説を試みる
とにかく分かりづらいTwelve-Factor Appの解説を試みる
Masatoshi Tada
 
Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)
Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)
Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)
NTT DATA Technology & Innovation
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのこと
Amazon Web Services Japan
 
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
Trainocate Japan, Ltd.
 
忙しい人の5分で分かるDocker 2017年春Ver
忙しい人の5分で分かるDocker 2017年春Ver忙しい人の5分で分かるDocker 2017年春Ver
忙しい人の5分で分かるDocker 2017年春Ver
Masahito Zembutsu
 
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
Preferred Networks
 
MQTTとAMQPと.NET
MQTTとAMQPと.NETMQTTとAMQPと.NET
MQTTとAMQPと.NET
terurou
 
DockerとPodmanの比較
DockerとPodmanの比較DockerとPodmanの比較
DockerとPodmanの比較
Akihiro Suda
 
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
20211209 Ops-JAWS Re invent2021re-cap-cloud operations20211209 Ops-JAWS Re invent2021re-cap-cloud operations
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
Amazon Web Services Japan
 
[GKE & Spanner 勉強会] GKE 入門
[GKE & Spanner 勉強会] GKE 入門[GKE & Spanner 勉強会] GKE 入門
[GKE & Spanner 勉強会] GKE 入門
Google Cloud Platform - Japan
 
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
NTT DATA Technology & Innovation
 
Redisの特徴と活用方法について
Redisの特徴と活用方法についてRedisの特徴と活用方法について
Redisの特徴と活用方法について
Yuji Otani
 
Keycloakの実際・翻訳プロジェクト紹介
Keycloakの実際・翻訳プロジェクト紹介Keycloakの実際・翻訳プロジェクト紹介
Keycloakの実際・翻訳プロジェクト紹介
Hiroyuki Wada
 
Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Dockerからcontainerdへの移行
Dockerからcontainerdへの移行
Kohei Tokunaga
 
Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022
Amazon Web Services Japan
 

What's hot (20)

実運用して分かったRabbit MQの良いところ・気をつけること #jjug
実運用して分かったRabbit MQの良いところ・気をつけること #jjug実運用して分かったRabbit MQの良いところ・気をつけること #jjug
実運用して分かったRabbit MQの良いところ・気をつけること #jjug
 
Amazon EKS によるスマホゲームのバックエンド運用事例
Amazon EKS によるスマホゲームのバックエンド運用事例Amazon EKS によるスマホゲームのバックエンド運用事例
Amazon EKS によるスマホゲームのバックエンド運用事例
 
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
 
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
kubernetes初心者がKnative Lambda Runtime触ってみた(Kubernetes Novice Tokyo #13 発表資料)
 
分散トレーシング技術について(Open tracingやjaeger)
分散トレーシング技術について(Open tracingやjaeger)分散トレーシング技術について(Open tracingやjaeger)
分散トレーシング技術について(Open tracingやjaeger)
 
とにかく分かりづらいTwelve-Factor Appの解説を試みる
とにかく分かりづらいTwelve-Factor Appの解説を試みるとにかく分かりづらいTwelve-Factor Appの解説を試みる
とにかく分かりづらいTwelve-Factor Appの解説を試みる
 
Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)
Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)
Prometheus Operator 入門(Kubernetes Novice Tokyo #26 発表資料)
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのこと
 
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
AWSとオンプレミスを繋ぐときに知っておきたいルーティングの基礎知識(CCSI監修!)
 
忙しい人の5分で分かるDocker 2017年春Ver
忙しい人の5分で分かるDocker 2017年春Ver忙しい人の5分で分かるDocker 2017年春Ver
忙しい人の5分で分かるDocker 2017年春Ver
 
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
わかる!metadata.managedFields / Kubernetes Meetup Tokyo 48
 
MQTTとAMQPと.NET
MQTTとAMQPと.NETMQTTとAMQPと.NET
MQTTとAMQPと.NET
 
DockerとPodmanの比較
DockerとPodmanの比較DockerとPodmanの比較
DockerとPodmanの比較
 
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
20211209 Ops-JAWS Re invent2021re-cap-cloud operations20211209 Ops-JAWS Re invent2021re-cap-cloud operations
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
 
[GKE & Spanner 勉強会] GKE 入門
[GKE & Spanner 勉強会] GKE 入門[GKE & Spanner 勉強会] GKE 入門
[GKE & Spanner 勉強会] GKE 入門
 
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
 
Redisの特徴と活用方法について
Redisの特徴と活用方法についてRedisの特徴と活用方法について
Redisの特徴と活用方法について
 
Keycloakの実際・翻訳プロジェクト紹介
Keycloakの実際・翻訳プロジェクト紹介Keycloakの実際・翻訳プロジェクト紹介
Keycloakの実際・翻訳プロジェクト紹介
 
Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Dockerからcontainerdへの移行
Dockerからcontainerdへの移行
 
Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022
 

Similar to Amazon EKS上の開発体験を最大化するプレビュー環境の作り方

Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2
Amazon Web Services Japan
 
20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと
Amazon Web Services Japan
 
Cloud9で試すAWS IoT Greengrass V2
Cloud9で試すAWS IoT Greengrass V2Cloud9で試すAWS IoT Greengrass V2
Cloud9で試すAWS IoT Greengrass V2
Jun Ichikawa
 
20180613 AWS Black Belt Online Seminar AWS Cloud9 入門
20180613 AWS Black Belt Online Seminar AWS Cloud9 入門20180613 AWS Black Belt Online Seminar AWS Cloud9 入門
20180613 AWS Black Belt Online Seminar AWS Cloud9 入門
Amazon Web Services Japan
 
Migration to AWS part2
Migration to AWS part2Migration to AWS part2
Migration to AWS part2
Kameda Harunobu
 
[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-
[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-
[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-Amazon Web Services Japan
 
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
Junji Nishihara
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
Amazon Web Services Japan
 
(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介
(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介
(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介
Yukitaka Ohmura
 
20180220 AWS Black Belt Online Seminar - Amazon Container Services
20180220 AWS Black Belt Online Seminar - Amazon Container Services20180220 AWS Black Belt Online Seminar - Amazon Container Services
20180220 AWS Black Belt Online Seminar - Amazon Container Services
Amazon Web Services Japan
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
Amazon Web Services Japan
 
Interoperability of webassembly with javascript
Interoperability of webassembly with javascriptInteroperability of webassembly with javascript
Interoperability of webassembly with javascript
Takao Tetsuro
 
マルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみた
マルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみたマルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみた
マルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみた
桂一 中山
 
AWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザAWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザ
Noritaka Sekiyama
 
iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介
iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介
iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介
Amazon Web Services Japan
 
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
Amazon Web Services Japan
 
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
Amazon Web Services Japan
 
20200811 AWS Black Belt Online Seminar CloudEndure
20200811 AWS Black Belt Online Seminar CloudEndure20200811 AWS Black Belt Online Seminar CloudEndure
20200811 AWS Black Belt Online Seminar CloudEndure
Amazon Web Services Japan
 
Web appsとcleardbで作る簡単webサイト
Web appsとcleardbで作る簡単webサイトWeb appsとcleardbで作る簡単webサイト
Web appsとcleardbで作る簡単webサイト
Tsukasa Kato
 
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
Amazon Web Services Japan
 

Similar to Amazon EKS上の開発体験を最大化するプレビュー環境の作り方 (20)

Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2
 
20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと
 
Cloud9で試すAWS IoT Greengrass V2
Cloud9で試すAWS IoT Greengrass V2Cloud9で試すAWS IoT Greengrass V2
Cloud9で試すAWS IoT Greengrass V2
 
20180613 AWS Black Belt Online Seminar AWS Cloud9 入門
20180613 AWS Black Belt Online Seminar AWS Cloud9 入門20180613 AWS Black Belt Online Seminar AWS Cloud9 入門
20180613 AWS Black Belt Online Seminar AWS Cloud9 入門
 
Migration to AWS part2
Migration to AWS part2Migration to AWS part2
Migration to AWS part2
 
[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-
[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-
[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-
 
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
 
(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介
(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介
(AWS DevOps祭り 2018) AWS Management Toolsサービスアプデートのご紹介
 
20180220 AWS Black Belt Online Seminar - Amazon Container Services
20180220 AWS Black Belt Online Seminar - Amazon Container Services20180220 AWS Black Belt Online Seminar - Amazon Container Services
20180220 AWS Black Belt Online Seminar - Amazon Container Services
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
 
Interoperability of webassembly with javascript
Interoperability of webassembly with javascriptInteroperability of webassembly with javascript
Interoperability of webassembly with javascript
 
マルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみた
マルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみたマルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみた
マルチリージョン・マルチアカウント対応の柔軟な構築ツールを作ってみた
 
AWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザAWS で Presto を徹底的に使いこなすワザ
AWS で Presto を徹底的に使いこなすワザ
 
iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介
iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介
iot@Loft#14-LT4-AI /機械学習に活用できる AWSのエッジソリューションのご紹介
 
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
[PGConf.ASIA 2018]Deep Dive on Amazon Aurora with PostgreSQL Compatibility
 
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
 
20200811 AWS Black Belt Online Seminar CloudEndure
20200811 AWS Black Belt Online Seminar CloudEndure20200811 AWS Black Belt Online Seminar CloudEndure
20200811 AWS Black Belt Online Seminar CloudEndure
 
Web appsとcleardbで作る簡単webサイト
Web appsとcleardbで作る簡単webサイトWeb appsとcleardbで作る簡単webサイト
Web appsとcleardbで作る簡単webサイト
 
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
 

Amazon EKS上の開発体験を最大化するプレビュー環境の作り方

  • 1. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. D E V D AY N O V 9 , 2 0 2 2
  • 2. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon EKS上の 開発体験を最⼤化する プレビュー環境の作り⽅ ⼭﨑理弘(かたいなか) C - 2 SRE 株式会社リブセンス
  • 3. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⾃⼰紹介
  • 4. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⾃⼰紹介 • ⼭﨑理弘(かたいなか) • 株式会社リブセンス SRE • コンテナ関連の技術が好き • Twitter,GitHub: @katainaka0503
  • 5. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アジェンダ
  • 6. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アジェンダ • プレビュー環境とは • プレビュー環境の構成要素 • Amazon EKS上での ArgoCDとIstioを使った実装例 • プレビュー環境導⼊までのロードマップ • まとめ
  • 7. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境とは
  • 8. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. マイクロサービス開発での悩み • 呼び出される側のマイクロサービスの動作確認が⼤変 § 開発環境にデプロイするまで 他マイクロサービスと結合して動作確認できない • 動作確認は後からになりPR Reviewの精度が低下 § ローカルで動かして動作確認することもできるが、 ⼤量のマイクロサービスをローカルで動かすのは⼤変 • バグ修正Pull Requestが頻発
  • 9. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境とは • Pull Request(以降PR)のブランチから作成されたコンテナイメージを 他のマイクロサービスと結合して動作確認できる環境 § 既存の環境を壊したり占有したりしない § PR作成などのタイミングで⾃動で環境が作成される § PRごとに専⽤の特別なURLから動作確認できる – 例: “pr-1.preview.example.com”
  • 10. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素
  • 11. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 12. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 全体像
  • 13. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 14. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションをPRごとにデプロイ • PRからビルドしたイメージを、 開発環境と同様の設定でデプロイ • PRがマージされたら⾃動で削除
  • 15. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 16. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. クラスタの⼊り⼝でURLをヘッダに変換 • ヘッダ伝播で伝播させるため、 URLをヘッダに変換
  • 17. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 18. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションによるヘッダ伝播 • 上流から受け取った情報を 他のサービス呼び出し時に ヘッダで渡す • どのPRのプレビュー環境への アクセスかの情報を伝播
  • 19. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 20. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ルーティングの設定をPRごとにデプロイ • ヘッダ伝播で使うヘッダを元に トラフィックを振り分ける設定を PRごとにデプロイ • PRがマージされたら削除 • プレビュー環境⽤の設定に マッチしなければ、 既存の環境に流す設定も適⽤
  • 21. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. まとめると
  • 22. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon EKS上での Argo CDとIstioを使った実装例
  • 23. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 実装に使⽤する技術 • Argo CD • Istio • Open Telemetry
  • 24. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Argo CDとは • KubernetesクラスタとGitHub等を同期するGitOpsを実現するツール § GitHub上のコードを変更したら変更がクラスタに同期 • Image Updaterによるイメージの更新も • Application SetsによるPRごとのデプロイ機能
  • 25. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Istioとは • オープンソースのサービスメッシュの実装 § サービス間の通信をインターセプトして様々な便利機能を提供 • 可観測性の向上 § 分散トレーシング機能 • トラフィックの管理 § L7/L4情報によるルーティング • セキュリティの向上 § mTLSによる通信の暗号化 § ポリシーベースのアクセス制御
  • 26. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Open Telemetryとは • 分散トレーシングのベンダに依存しない規格および実装 • 様々な⾔語の主要なライブラリをカバーしたSDKを公式で提供 • AWS X-RayやDatadog APM等に結果を送信できる • SDKがBaggageヘッダによるヘッダ伝播の仕組みを提供 § BaggageはW3Cによるコンテキスト伝播のための規格
  • 27. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素(おさらい) • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 28. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 全体像
  • 29. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 30. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションをPRごとにデプロイ • ArgoCDで右図を実現する
  • 31. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションをPRごとにデプロイ • Pull Request Generatorで PRごとのデプロイを実現(①) • Image Updaterで ビルドされたイメージに 更新させる(②) apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: frontend-pr-env namespace: argocd spec: generators: - pullRequest: github: owner: katainaka0503 repo: grpc-pr-env-test-frontend template: metadata: name: '{{branch}}-frontend’ namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io annotations: argocd-image-updater.argoproj.io/image-list: app=<image> argocd-image-updater.argoproj.io/app.update-strategy: latest argocd-image-updater.argoproj.io/app.allow-tags: regexp:{{branch}}-.* argocd-image-updater.argoproj.io/write-back-method: git spec: project: default source: repoURL: <repo> path: <kustomize path> targetRevision: master kustomize: namePrefix: '{{branch}}-' ① ②
  • 32. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 33. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. クラスタの⼊り⼝でURLをヘッダに変換 • Nginx等のアプリケーションで URLをヘッダに変換 upstream frontend { server frontend.default.svc.cluster.local:80; } server { listen 80 http2; # 正規表現でbaggageヘッダに使う値を取得 server_name ~^(?<branch>.+)¥.preview¥.example¥.com$; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Real-IP $remote_addr; # baggageヘッダを設定 proxy_set_header baggage branch=${branch}; location / { proxy_pass http://frontend; } }
  • 34. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 35. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションによるヘッダ伝播 • OpenTelemetryにより baggageヘッダが伝播
  • 36. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションによるヘッダ伝播 // Bagggageによる伝播を有効化 otel.SetTextMapPropagator(propagation.Baggage{}) // InterceptorでOpenTelemetryを仕込む s := grpc.NewServer(grpc.UnaryInterceptor(otelgrpc.UnaryServerInterceptor()), grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor())) pb.RegiterGreeterServer(s, &server{}) サ ー バ 側 の 実 装 ( G R P C )
  • 37. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションによるヘッダ伝播 // Baggageを有効化 otel.SetTextMapPropagator(propagation.Baggage{}) // InterceptorでOpenTelemetryを仕込む conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()), grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor())) ク ラ イ ア ン ト 側 の 実 装 ( G R P C )
  • 38. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境の構成要素 • アプリケーションをPRごとにデプロイ • クラスタの⼊り⼝でURLをヘッダに変換 • アプリケーションによるヘッダ伝播 • ルーティングの設定をPRごとにデプロイ
  • 39. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ルーティングの設定をPRごとにデプロイ • 右図をArgoCD + Istioで実現
  • 40. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ルーティングの設定をPRごとにデプロイ • Baggageヘッダを元に ルーティング • PRごとにデプロイした際に 優先順位で問題が⽣じない Gateway APIを使⽤ apiVersion: gateway.networking.k8s.io/v1alpha2 kind: HTTPRoute metadata: name: {{ .Release.Name }} spec: parentRefs: - kind: Mesh name: istio hostnames: ["{{ .Values.app }}.default.svc.cluster.local"] rules: - matches: - headers: - type: RegularExpression name: baggage value: ^(.*¥s*;)?branch¥s*=¥s*{{ .Values.branch }}(¥s*;.*)?$ backendRefs: - name: {{ .Values.branch }}-{{ .Values.app }} port: 80
  • 41. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ルーティングの設定をPRごとにデプロイ • Application Setで設定を複製 apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: backend-pr-env-routing namespace: argocd spec: generators: - pullRequest: github: owner: katainaka0503 repo: grpc-pr-env-test-backend template: metadata: name: '{{branch}}-backend-routing’ namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io spec: project: default source: repoURL: <repo URL> path: <helm path> targetRevision: master helm: releaseName: backend-{{ branch }}-pr parameters: - name: branch value: '{{ branch }}’ - name: app value: <app name>
  • 42. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. まとめると
  • 43. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. デモ
  • 44. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 実際の環境に適⽤するには § 実装上の制限 – Image Updaterが作成するファイルを定期的に消す § コスト⾯ – Preview環境のPodのCPU・メモリを最⼩限に – GitOpsの⼒を借りて必要な部分だけPRごとにデプロイ § セキュリティ⾯ – レビューが通っていない差分のSQLが実⾏されるのでDBの権限を絞る – プレビュー環境のURLで画像等が取得できるようCORSの設定変更
  • 45. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. プレビュー環境導入までの ロードマップ
  • 46. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 現実 • ここまで紹介したような仕組みをいますぐ⼊れようと頑張るのが、 すべての組織にとってベストというわけではない § 構成要素が多いため プレビュー環境のためだけに導⼊するのは⼤変 § 構成要素が新しいのでキャッチアップコストがかかる
  • 47. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⼀⽅で • プレビュー環境の実装に使えるツールは プレビュー環境が関係ない⽂脈でも便利 § Argo CD § Istio § Open Telemetry
  • 48. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 提案 • まずは運⽤負荷・導⼊コストが低いよりライトな仕組みを実現する • 分散トレーシングやサービスメッシュをサービスの成⻑に合わせて 順番に導⼊する § 技術選定の基準にPreview環境の実現可能性も加える • 仕組みが整い、開発⼈数も増え、ビジネスも成⻑したタイミングで プレビュー環境を導⼊する
  • 49. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. よりライトな仕組みの例 • PRマージ時のステージングデプロイ • ブランチを指定してステージングにデプロイ • フロントエンドだけプレビュー環境を⽤意
  • 50. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. PRマージ時のステージングデプロイ • ⼀般的なCI/CD • 開発初期ではこれで充分な場合も多そう • モノリスをごく少⼈数で開発しているケース等、 ローカルで動作確認できるならこれで⼗分な場合も
  • 51. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ブランチを指定してステージングにデプロイ • mainブランチではないブランチも指定して デプロイできるようにする • ステージングを⼀時的に占有して動作確認 • ステージングを占有するので開発⼈数が増えると待ちが発⽣する
  • 52. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. フロントエンドにだけプレビュー環境を⽤意 • フロントエンドだけならヘッダ伝播のしくみは不要 § モノリスの場合も同様の理由で不要な場合あり • 重要なロジックが各マイクロサービスに移譲されるに従って カバーできるケースが減る • Amplify Hosting等既存サービスが使える場合も
  • 53. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. ロードマップのスケッチ例 • サービスが軌道に乗るまで § 最低限のCI/CD • 運⽤改善に⼿を回せるようになったら § Open Telemetryで分散トレーシングを⼊れる § フロントだけのプレビュー環境を⽤意する • 開発⼈員を増やして更に開発本格化するときには § マイクロサービス化 or BFFの導⼊に合わせて ブランチデプロイを導⼊ • さらに開発⼈員やマイクロサービスの数が増えてきたら § Istioでプレビュー環境を⽤意
  • 54. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. まとめ
  • 55. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. まとめ • プレビュー環境の構成要素 § アプリケーションのPRごとのデプロイ § URLをヘッダに変換 § アプリケーションによるヘッダ伝播 § ルーティングの設定のPRごとにデプロイ • プレビュー環境を無理に急いで作ろうとせず、 サービスの成⻑に合わせて計画的に
  • 56. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you! © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.