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
ex-app-on-k8s
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ohr486
November 09, 2019
Programming
270
0
Share
ex-app-on-k8s
ohr486
November 09, 2019
More Decks by ohr486
See All by ohr486
負荷試験Night#1 負荷試験2023年トレンド
ohr486
17
4.8k
Elixir/PhoenixによるWeb開発の現場から
ohr486
1
650
Hacking Phoenix Performance
ohr486
1
400
Plug & WAF
ohr486
2
550
elixirをプロダクションに導入する
ohr486
1
730
IEx maniacs
ohr486
4
660
Hack and Read Elixir
ohr486
2
810
Running App on AppRunner
ohr486
0
860
sponsor-talk-drecom-heisei-ruby-kaigi
ohr486
0
910
Other Decks in Programming
See All in Programming
ECR拡張スキャンでSBOMを収集して サプライチェーン攻撃の影響調査を 爆速で終わらせてみた
akihisaikeda
2
210
AI Agent と正しく分析するための環境作り
yoshyum
3
640
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
280
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
130
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
210
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
11
3k
要はバランスからの卒業 #yumemi_grow
kajitack
0
200
開発とはなにか、Essenceカーネルで見えるもの
ukin0k0
0
220
AI 時代のソフトウェア設計の学び方
masuda220
PRO
28
11k
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.1k
色即是空、空即是色、データサイエンス
kamoneggi
1
200
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.3k
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
21k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
So, you think you're a good person
axbom
PRO
2
2k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
190
The untapped power of vector embeddings
frankvandijk
2
1.7k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
210
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Transcript
Elixir app on k8s 2019/11/09 週1ゆるもく会 @ohrdev
agenda • about me • target • goal • elixir
• kubernetes(k8s) • our tools for service/deployment • our service architecture • our deployment diagram • release build for elixir • conclusion
about me • Tsunenori Ohara/おーはら ◦ Twitter: @ohrdev ◦ Github:
ohr486 • Work ◦ Drecom ◦ SRE/Infra/Ruby,Elixir,Lisp,etc • Community ◦ tokyo.ex, ElixirConfJapan, Erlang&ElixirFest オーガナイザー ◦ Japan Elixir Association ◦ meguro.rb, meguro.es • Hobby ◦ 仏像制作, 丸太収集, 写経, 寺社仏閣 ◦ 人工衛星/アマチュア無線
target • アプリの実行環境をサーバーからコンテナに変更したい人 • k8s環境へのアプリのデプロイ方法を知りたい人 • (k8sちょっと興味がある勢) • (elixirちょっと興味ある勢)
goal • elixirアプリを例に、以下の内容がわかる • k8s環境へアプリをdeployする方法 • deployの為に必要なツール • k8s上で動くサービスのインフラ/アーキテクチャ/構成
elixir • ErlangVM上で動作 • 関数型言語 • モダンな開発環境/ツール • 並行プログラミング ◦
Actor Model • 軽量プロセス ◦ OSのプロセスとは異なる ◦ 超軽量 • OTP(Open Telecom Platform) ◦ 並行プログラミングのパターン /FW
7 Erlang VM Architecture Linux Server Erlang VM CPU CPU
CPU CPU CPU CPU コア数と同数のスケジューラー erlang process != OS process VMがスケジューラー間のプロセスを分 散/マイグレーション スケジューラー プロセス
8 Erlang PROCESS Architecture Erlang VM application controller application master
application プロセス ・elixir, iex, mix, etc ・user apps ・lib apps
kubernetes(k8s) • コンテナのオペレーションを自動化するプラットフォーム ◦ アプリの自動デプロイ ◦ スケーリング ◦ アプリ・コンテナ運用 •
OSS • 自前運用も可能だが、マネージドなクラウドサービスを使うのが一般的 ◦ GCP : GKE <= よく使われている、事例があがるやつ ◦ AWS: EKS <= 今日のターゲット ◦ Azure: AKS
our tools for service/deployment • インフラ ◦ EKS(Elastic Kubernetes Service)
▪ AWSのマネージドなk8sサービス ◦ ECR(Elastic Container Registry) ▪ AWSのDockerコンテナのレジストリサービス ◦ ALB(Application Load Balancer) ▪ AWSのロードバランサー ◦ EC2(Elastic Compute Cloud) ▪ AWSのマネージドな仮想サーバー • CI/CD ◦ CircleCI ◦ GitHub ◦ Chatwork
EKS cluster worker node群 our service architecture ALB service pod
elixir app container ECR AutoScalingGroup EC2 Instance EC2 Instance EC2 Instance end user developer CD tools kubectl git push configmap deployment … etc
CircleCI workflow our deployment diagram test lint release build aws
auth docker push kubectl apply docker build 言語による違 いはここ push message 各種通知 webhooks start CI/CD deploy/更新 はk8sが実行 v1.1の imageを pull tag: v1.1 v1.1の imageを 適用
release build for elixir • elixirはコンパイル言語 • elixirのリリースアーカイブ作成機能 ◦ 言語ランタイムも一緒にアーカイブしてくれる
◦ つまり、同じOS/アーキテクチャのサーバーであれば、ファイルを copyするだけで実行可能 ▪ つまり、実行環境にelixirをインストールしなくても良い ◦ dockerで動かす場合は、docker buildでイメージにランタイム毎焼けば良い • workflow ◦ strep0. mix deps.get ◦ step1. MIX_ENV=prod mix compile ◦ step2. MIX_ENV=prod mix release ◦ step3. cp _build/prod/<app> /path/to/app <= /path/to/app を含めてdocker buildすれば良い ◦ step4. /path/to/bin/<app> start
conclusion • k8s環境へのdeploymentの事例を紹介しました • 言語によらずほぼしくみは同じだと思います ◦ つまりRailsだろうがGolangだろうが同じ仕組みで適用可能だと思います • k8sを利用する事でdeploymentオペレーションをシンプルにできます •
クラウドが提供するマネージドk8sを利用するとk8sの管理も不要になるのでとても 管理が楽になります