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
150
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
710
kube-system落としてみました
tarosaiba
8
2.9k
コンテナ技術とコンテナオーケストレーション 入門_改訂版
tarosaiba
0
680
コンテナ技術とコンテナオーケストレーション入門
tarosaiba
0
940
Other Decks in Technology
See All in Technology
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
MulticaとPi Coding Agentで、小規模OSSを30本同時運用した流れ
eiei114
0
110
サイバー捜査員研修(後半)
nomizone
1
880
ガバメント AI 源内を地方自治体は活用できるのか可能性と課題、期待について
takeda_h
1
410
私がブラウザを自作したくなった理由
supurazako
1
240
AIエージェントを前提としたプラットフォーム エンジニアリング:GKEで作るAgent-Ready Golden Path
legalontechnologies
PRO
2
240
20260804_Q4AzureUpdateBite_FabricDataAgentの精度を高める設計.pdf
matayuuu
1
140
FPGAが実現する遠方宇宙の高空間分解能天体撮影 -大型地上望遠鏡の視力を補正する「補償光学」とは?-
komei_mt
0
250
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
300
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
200
モノリス Rails でも日中に rails db:migrate を走らせたい! / Daytime rails db:migrate on Monolithic Rails!
euglena1215
4
590
え?フロントエンドエンジニアの ワイがインフラも!?
puku0x
1
590
Featured
See All Featured
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
380
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
200
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
300
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
390
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
390
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
650
Accessibility Awareness
sabderemane
1
180
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Navigating Team Friction
lara
192
16k
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 おわり