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
ElasticContainerServicesハンズオン
Search
tarosaiba
February 28, 2019
Technology
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ElasticContainerServicesハンズオン
tarosaiba
February 28, 2019
More Decks by tarosaiba
See All by tarosaiba
合格対策 GOOGLE CLOUD CERTIFIED Professional Cloud Architect 編
tarosaiba
2
700
kube-system落としてみました
tarosaiba
8
2.9k
コンテナ技術とコンテナオーケストレーション 入門_改訂版
tarosaiba
0
670
コンテナ技術とコンテナオーケストレーション入門
tarosaiba
0
930
Other Decks in Technology
See All in Technology
本当の”仕事”を手放せる未来が見えた
mu7889yoon
0
170
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
150
AIをフル活用してオンコール機能のプロトタイプを2日で作った話 / Building an AI-Powered On-Call Prototype in Just Two Days
nari_ex
0
140
アラート調査向けAIエージェントの本番導入とその後/AI Agents for Alert Investigation: Production Deployment and After
taddy_919
1
240
作る力から、見極める力へ — AI時代に広がるエンジニアの価値と役割
rince
0
360
Zenoh on Zephyr on LiteX
takasehideki
2
120
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
210
AI-DLCを “そのまま導入しなかった”話 ~組織に合わせてアジャストした 私たちの実践共有~
hiroramos4
PRO
1
440
フルAIで個人開発して学んだあれこれ / yuruai vol.1
isaoshimizu
0
150
サイバーエージェントにおけるAI推進戦略と変革への取り組み
shotatsuge
0
600
【FinOps】データドリブンな意思決定を目指して
z63d
2
470
iOS アプリの「これって不具合ですか?」を AI に調べてもらう
miichan
0
150
Featured
See All Featured
Mind Mapping
helmedeiros
PRO
1
260
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
ラッコキーワード サービス紹介資料
rakko
1
3.7M
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
290
Balancing Empowerment & Direction
lara
6
1.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
620
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
2
250
Music & Morning Musume
bryan
47
7.2k
Statistics for Hackers
jakevdp
799
230k
Transcript
Elastic Container Services 編 2019/2/04 Shuntaro Saiba これからのアプリケーションデプロイが変わる 1
@tarosaiba • Future Architect, Inc • TIG所属 4年目 • Infra
- MW - CI 周りやってきました • AWS/GCP • Infrastructure as Codeの導入が得意 http://www.atmarkit.co.jp/ait/articles/1806/05/news010_2.html Shuntaro Saiba 2
3 私のいままで エンプラ小売り & AWS エンプラ金融 & オンプレ エンプラ小売り &
GCP エンプラ小売り & AWS
4 私のいままで エンプラ小売り & AWS エンプラ金融 & オンプレ エンプラ小売り &
GCP エンプラ小売り & AWS 本番環境でコンテナ運 用を経験
注意 - アイコンが変わりました • AWSのアイコンが2018/10月頃に変わったので、本資料は新しいので作成し てみます。 (慣れなくて見づらい..) 5 NEW! ECS
Container
6 https://speakerdeck.com/tarosaiba/kontenaji-shu-tokontenaokesutoresiyonru-men こちらの資料も見てください!
想定読者 • ECSが便利なのは知ってるけど、どうやって使えばよいの? • 「Service」「Task」って何!? • これからのAWSでのシステム構築、アプリデプロイはどう変わっていくの? 7
ECS (Elastic Container Service) 8 • AWSのマネージドサービス • AWS独自のコンテナオーケストレーションツール •
Docker コンテナフォーマットをサポート
ECS の簡単な仕組み 9 ECS Cluster EC2 EC2 Service Task Task
・・・ • EC2でクラスタを構成 • Task(=コンテナ)で コンテ ナイメージを指定 • ServiceでTask数を指定
10 とりあえず
11 今回のゴール • Fargateで動くコンテナ上の アプリにアクセスできるまで ECS Cluster Fargate Service ENI
Task
12 でどんどんデプロイ していきます
今回やること 13 ECS Cluster App Source Dockerfile Image COMMIT DEPLOY
Service Task Docker BUILD Docker PUSH AWS Service ECR Registry 1 2 3 4
今回やること 14 No やること 内容 方法 Commit • Dockerfileと APP
のソースコードを作成 • N/A Docker Build • Docker の Image を作成 • docker build Docker Push • Docker Imageを ECR に Push • AWS コンソール • docker push Deploy to ECS • ECR の Cluster、Service作成 • Task をデプロイ • AWS コンソール 1 2 3 4
15 1. Commit
1. Commit 16 Container Image • 以下を作成しましょう Build App Source
Dockerfile
Sample Java Source • こちらのSampleプログラムを 使います。 https://github.com/spring-projects/spring-petclinic • maven で
ビルド • jar が作成されたことを確認 17 # Git Clone > git clone https://github.com/spring-projects/spring-petclinic # Build springboot source > mvn clean install [INFO] Scanning for projects... Downloading from spring-snapshots: .. [INFO] -------------------------------------------------------------- [INFO] BUILD SUCCESS -------------------------------------------------------------- > ls target/*.jar target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar
Sample Java Source • 動かしてみましょう 18 # Start Springboot >
java -jar ./target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar
Sample Dockerfile • Dockerfile を作成します • CentOS7にopenjdkをインストールし ビルド済みのjarをコンテナにコピー • ポートの公開設定をして、jarを起動
19 # ベースのイメージを指定 FROM centos:7 # yumでJavaをInstall RUN yum update -y && \ yum install -y java-1.8.0-openjdk # 作業ディレクトリに移動 WORKDIR /app # jarをコンテナにコピー COPY ./target/spring-petclinic-xxx.jar /app # ポートの公開設定 EXPOSE 8080 # コンテナ内でmy-app.jarを実行 CMD ["java", "-jar", "/app/spring-petclinic-xxx.jar"] # Make Dockerfile at same directry > vim Dockerfile Dockerfile pom.xml readme.md src target
20 準備完了です
21 2. Build
2. Build 22 Container Image • Build します Build App
Source Dockerfile
Docker build • docker build コマンドでイメージを作 成します 23 # Check
files > ls Dockerfile pom.xml readme.md src target # Docker build > docker build -t sample-springboot:latest . Sending build context to Docker daemon 57.15 MB Step 1/6 : FROM centos:7 ---> 1e1148e4cc2c Step 2/6 : RUN yum update -y && yum install -y java-1.8.0-openjdk ---> Running in a019ed4047fe .. Step 6/6 : CMD java -jar /app/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar ---> Running in 1444a0955841 ---> 86de299b51bc Removing intermediate container 1444a0955841 Successfully built 86de299b51bc
コンテナにアプリを入れる 24 Container Image Bins/Libs App • コンテナのイメージが出来上がりました! Build
25 3. Push
26 ここから が登場
ECR 作成 27 • Docker Image を管理する ECRのリポジトリを作成します
28 ECR 作成 • リポジトリ名を入れて、作成
29 ECR 作成 • リポジトリできました (sample-springboot) Repogitory
30 Docker login • ECRにpushするための準備を 行います Repogitory
31 # Get docker command > (aws ecr get-login --no-include-email
--region ap-northeast-1) docker login -u AWS -p ******************************************************************************************** ******************************************************************************************** ******************************************************************************************** ******************************************************************************************** ********* https://xxxxxxxxxxxxx3.dkr.ecr.ap-northeast-1.amazonaws.com Login Succeeded Docker login • ECRにPushするために、Login します Repogitory
32 # Get docker command > docker tag sample-springboot:latest ***.dkr.ecr.ap-northeast-1.amazonaws.com/sample-springboot:latest
> docker images REPOSITORY TAG IMAGE ID CREATED SIZE ***.dkr.ecr.ap-northeast-1.amazonaws.com/sample-springboot latest 86de299b51bc 26 hours ago 541 MB > docker push ***.dkr.ecr.ap-northeast-1.amazonaws.com/sample-springboot:latest The push refers to a repository [***.dkr.ecr.ap-northeast-1.amazonaws.com/sample-springboot] 30d8f279a479: Pushing [======> ] 5.965 MB/44.61 MB a419c287f8fe: Pushing 1.536 kB a1474341a13e: Pushing [=> ] 7.739 MB/294.7 MB 071d8bd76517: Pushing [> ] 2.735 MB/201.8 MB Docker push • Docker buildします • ECRにPushします Repogitory
33 Docker push • Docker Imageを pushできました Repogitory Docker Image
34 4. Deploy
ECS Cluster 作成 35 • ECS Clusterを作ります Repogitory Docker Image
36 ECS Cluster 作成 • ECS Clusterを作ります • AWS Fargateを選択
Repogitory Docker Image
37 ECS Cluster 作成 • ECS Clusterの名前を指定 (ecs-cluster-sample-springboot) Repogitory Docker
Image
38 ECS Cluster 作成 • ECS Clusterできあがりました Repogitory Docker Image
ECS Cluster Fargate
39 ECS Cluster 作成 • ECS Clusterできあがりました Repogitory Docker Image
ECS Cluster Fargate
40 ECS タスク定義 作成 • タスク定義を作成します Repogitory Docker Image ECS
Cluster Fargate
41 ECS タスク定義 作成 • 起動タイプ : FARGATE を指定 Repogitory
Docker Image ECS Cluster Fargate
42 ECS タスク定義 作成 • 定義名 (ecs-task-sample-springboot) • ネットワーク: awsvpc
を指定 Repogitory Docker Image ECS Cluster Fargate
43 ECS タスク定義 作成 • メモリとCPUを指定 Repogitory Docker Image ECS
Cluster Fargate
44 ECS タスク定義 作成 • コンテナの定義 • pushしたECRのイメージを指定 Repogitory Docker
Image ECS Cluster Fargate
45 ECS タスク定義 作成 • リッスンさせるポートを指定 (8080) Repogitory Docker Image
ECS Cluster Fargate
46 ECS タスク定義 作成 • タスク定義ができました Repogitory Docker Image ECS
Cluster Fargate Task Definition
47 ECS Service 作成 • Serviceを作成します Repogitory Docker Image ECS
Cluster Fargate Task Definition
48 ECS Service 作成 • 先に作成したタスク定義を指定 • タスク数は1 Repogitory Docker
Image ECS Cluster Fargate Task Definition
49 ECS Service 作成 • VPC、サブネット、セキュリティグルー プを指定 • パブリックIP は有効
Repogitory Docker Image ECS Cluster Fargate Task Definition
50 ECS Service 作成 • サービスの検出は OFF ECS Cluster Fargate
Repogitory Docker Image Task Definition
51 ECS Service 作成 • サービスできました ECS Cluster Fargate Service
ENI Task Repogitory Docker Image Task Definition
52 アクセス確認 • パブリックIPにアクセス • アプリにアクセスできました ECS Cluster Fargate Service
ENI Task Repogitory Docker Image Task Definition
53 おわり