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
680
コンテナ技術とコンテナオーケストレーション入門
tarosaiba
0
930
Other Decks in Technology
See All in Technology
Power Automateアップデート情報
miyakemito
0
120
探索・可視化・自動化を一本化 Amazon Quickでデータ活用スピードを上げる方法
koheiyoshikawa
0
180
仕様駆動開発、導入半年。「本当に速くなってるの?」にデータで答える / AICon2026_hirakawa
rakus_dev
0
330
AIが当たり前の組織で エンジニアはどう育つか
nishihira
1
990
「守りたい体験」を渡すだけで E2E を生成させられるようになった話
hinac0
2
1k
「顧客の声を聞かなければ何も始まらない」 ── 顧客の声から生まれた『AI返信補助機能』の開発プロセス / AICon2026_shikata_imai
rakus_dev
1
270
「休む」重要さ
smt7174
6
1.6k
副作用のある Lambda でも Lambda Power Tuning は使えるのか / lambda-power-tuning-side-effects
koukihosaka
2
150
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
620
アップデートで何が変わった?デモで学んで使いこなすIBM Bob2.0
muehara
0
230
AI時代におけるエンジニアの新たな役割──FDEとクオリアの探求/登壇資料(戸井田 裕貴)
hacobu
PRO
0
330
データエンジニアリングとドメイン駆動設計
masuda220
PRO
14
2.5k
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
370
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
560
The untapped power of vector embeddings
frankvandijk
2
1.8k
Making Projects Easy
brettharned
120
6.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Into the Great Unknown - MozCon
thekraken
41
2.6k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
250
A better future with KSS
kneath
240
18k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
270
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 おわり