開発環境の稼働スケジュールをNotionで管理してみた(WealthNavi Tech Talk vol.0)

1.6K Views

November 13, 23

スライド概要

profile-image

ウェルスナビ株式会社 技術広報チームの公式アカウントです。

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

関連スライド

各ページのテキスト
1.

開発環境の稼働スケジュール をNotionで管理してみた WealthNavi Tech Talk vol.0 1

2.

登壇者と所属チーム ウェルスナビ株式会社 システム基盤チーム インフラエンジニア ・TechLead SIerを経て2018年1月ウェルスナビにインフラエンジニアとし て入社。最近は ECSやEKSのパイプライン整備やコンテナ 化を推進中。 和田 雄樹 システム基盤チームについて manager メンバーのバックグラウンド 開発経験があるメンバーが多いです 開発(+インフラ )経験 チームの業務内容 ● WealthNaviの運用と技術課題の解決 ● サービス共通基盤の設計、開発 ● 新規事業の基盤構築 インフラ経験 チームの技術スタック ● プラットフォーム: AWS/GCP ● 実行基盤:ECS/EC2/EKS ● 開発言語:Go ● IaC:Terraform ● 監視:Datadog/PagerDuty 2 サービス共通基盤(メール送信基盤)の開発事例

3.

開発環境について(2023年6月時点) ● 開発環境 ○ 開発環境は 4 断面 ○ 各断面のECSサービス数は 60 以上(最近やたら増えた) ● 開発環境の要件 ○ ○ ○ ○ 開発内容によって必要なECSサービスが違う 開発内容によって専用のDBが必要になる場合がある 開発環境を触るのは 4 チーム(開発チームx3、QAチーム) 稀に夜間や休日に開発環境を使うことがある コンテナ化が進みECSが多数派に 3

4.

背景と課題 ● 開発組織の拡大に伴い、並行開発のニーズが高まる ● 開発環境のAWSコストが増加 ○ 開発完了後の停止忘れも多い ● 開発環境の管理コストも増加 ○ 休日夜間に開発環境を利用する場合、インフラチームに延長依頼を行う 必要がある ○ ECSサービス数が多く、依存関係の把握が難しい Centralized Provisioningから Platform-enabled Golden Path パターンに移行してスケールさせたい 引用:How organizations are modernizing for cloud operations https://aws.amazon.com/jp/blogs/devops/how-organizations-are-modernizing-for-cloud-operations/ 4

5.

対応の方向性 ● 管理画面のUIは Notion を使う ○ ドキュメント・プロジェクト管理ツールとして社内で普及している ○ 利用スケジュールをデータベース(Timeline View)で管理できる ○ APIが使える ● なるべく既存の仕組みを活用する ○ ECSのtaskdefをモノレポ管理している 詳細はテックブログをご確認ください https://tech.wealthnavi.com/entry/20230228/1677551542 5

6.
[beta]
ecspressoとは
● ECS向けの軽量デプロイツール
https://github.com/kayac/ecspresso
ディレクトリ構造(例)
products
├── app1-web
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json
├── app1-api
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json
services
├── creditcard-api
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json
├── apyment-api
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json

ecspresso.json
{
"cluster": "stg-servicesite",
"region": "ap-northeast-1",
"service": "app1-web",
"task_definition": "taskdef.json",
"timeout": "10m0s"
}

デプロイ
$ ecspresso deploy --config
products/app1-web/stg/ecspresso.yml

起動
$ ecspresso scale –tasks 1 --config
products/app1-web/stg/ecspresso.yml

停止
$ ecspresso scale –tasks 0 --config
products/app1-web/stg/ecspresso.yml
6

7.
[beta]
ecspressoの良さ
● 操作対象指定が直感的
ディレクトリ構造(例)
products
├── app1-web
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json
├── app1-api
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json
services
├── creditcard-api
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json
├── apyment-api
│ └── stg
│
├── ecspresso.json
│
└── taskdef.json

ecspresso.json
{
"cluster": "stg-servicesite",
"region": "ap-northeast-1",
"service": "app1-web",
"task_definition": "taskdef.json",
"timeout": "10m0s"
}

デプロイ
$ ecspresso deploy --config
設定ファイルのパスを指定するだけ
products/app1-web/stg/ecspresso.yml

起動
$ ecspresso scale –tasks 1 --config
products/app1-web/stg/ecspresso.yml

停止
$ ecspresso scale –tasks 0 --config
products/app1-web/stg/ecspresso.yml
7

8.

ecspressoの良さ ● 操作対象指定が直感的 ディレクトリ構造(例) products ├── app1-web │ └── stg │ ├── ecspresso.json │ └── taskdef.json ├── app1-api │ └── stg │ ├── ecspresso.json │ └── taskdef.json services ├── creditcard-api │ └── stg │ ├── ecspresso.json │ └── taskdef.json ├── apyment-api │ └── stg │ ├── ecspresso.json │ └── taskdef.json 設定ファイルを 前方一致で一括選択できる 複数起動 $ find products/app1* -name ecspresso.json | \ xargs -I@ -P4 -n1 sh -c “\ ecspresso scale –tasks 1 --config @ –no-watit” 複数停止 $ find products/app1* -name ecspresso.json | \ xargs -I@ -P4 -n1 sh -c “\ ecspresso scale –tasks 0 --config @ –no-watit” 8

9.

できあがった仕組み ※DBは既存のLambdaを活用した(詳細は省略) 9

10.
[beta]
管理画面の利用イメージ
● 必要なECSやAuroraリソースを列挙してAPIで読み取る

Notion APIのリクエスト

Notion APIのレスポンス

$ curl --silent --location --request POST
https://api.notion.com/v1/databases/<DBのID>/query \
--header 'Notion-Version: 2022-06-28' \
--header "Authorization: Bearer ${NOTION_API_KEY}" \
--header "Content-Type: application/json" \
--data '{
"filter": {
"property": "ステータス",
"status": {
"equals": "利用中"
}
}
}'

{
"object": "list",
"results": [
{
"properties": {
"コンポーネント": {
"id": "Ijdj",
"type": "multi_select",
"multi_select": [
{
"id": "fd95540a-67ee-4a44-8e8a-8a8c4157b6d4",
"name": "db/stg-aurora"
},
{
"id": "86446023-546b-4ac7-a913-8fa0879ba3cd",
"name": "products/servicesite"
}
]
},
…
10

11.

管理画面の利用イメージ ● テンプレート機能でよくある組み合わせを管理 $ find {products/servicesite-hoge*,products/servicesite-fuga*,services/creditcard*,services/payment*} -name ecspresso.json | \ xargs -I@ -P4 -n1 sh -c “\ ecspresso scale –tasks 1 --config @ –no-watit” 11

12.

管理画面の利用イメージ ● TimelineViewで利用期間を可視化 12

13.

効果 ● AWSコスト ○ 90%+α削減(Fargate Spot x 稼働時間調整) 削減手段 結果(削減率) 前提 Fargate Spot 70%(対オンデマンド) 本番環境以外は FargateSpotを利用する ● ● 稼働時間調整 67.2%(対常時稼働) +α%(必要最小限の ECS サービス) オンデマンド: 0.05056 USD/時間 FargateSpot : 0.01542202 USD/時間 今回の仕組みで実現 ● ● 平日12時間/日 稼働 必要なECSサービスのみ起動 ● 管理コスト ○ いい感じに削減 対応手段 結果 開発者がオンデマンドで開発環境を管理 権限移譲により対応コスト削減 開発内容に応じて必要な ECSサービスをパ ターン化 Notionのテンプレート機能により、認知負荷の軽減 稼働スケジュールを見える化 NotionのTimeline機能により、管理コスト削減 13

14.

今後について Datadog Service Catalogを軸に ミニ内部開発者ポータルを提供 14

15.

まとめ ● 管理画面UIとしてのNotionはあり ○ MultiSelect、TimelineView、Templateが便利 ● ecspresso定義をモノレポで管理するといい感じ ○ 操作対象の指定が直感的 ● 要件や構成がシンプルであれば、StepFunctionをスケジュール 実行する方がよさそう ○ AWS SDKのサービスの統合 15

16.

おしらせ 一緒に働く仲間(SRE)を募集中です!※2023年11月現在 https://hrmos.co/pages/wealthnavi/jobs/1839975184289607681 16

17.

Mission 働く世代に豊かさを Vision 「ものづくり」する金融機関 Values 誠実に、正直に、お客様のために 助け合おう、向き合おう 一歩を重ねて、大きな前進を 17