This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

AWS Fargateハンズオン

Last updated at Posted at 2018-03-16
1 / 37

http://bit.ly/2Gwvmcs


チュートリアル


以下のリンクにアクセス。
https://console.aws.amazon.com/ecs/home?region=us-east-1#/firstRun


Step 1: Container and Task

何も変更せずに、Nextをクリック
Screen Shot 2018-03-16 at 10.48.47 AM.png


Step 2: Service

ロードバランサを利用したいので、Application Load Balancerを選択してから、Nextをクリック
Screen Shot 2018-03-16 at 10.49.20 AM.png


Step 3: Cluster

何も変更せずに、Nextをクリック
(もしCluster nameが既にあると警告されたら適当な名前に変更)
Screen Shot 2018-03-16 at 10.49.28 AM.png


Step 4: Review

Createをクリック
Screen Shot 2018-03-16 at 10.49.37 AM.png


作成完了

5分程度待つと全て作成が完了する
View serviceをクリック
Screen Shot 2018-03-16 at 10.53.44 AM.png


Serviceの情報を確認する

Screen Shot 2018-03-16 at 11.03.21 AM.png


Serviceのログを見てみる

Logsタブをクリックすると、アプリケーションが出力しているアクセスログが確認できる
(ALBからのヘルスチェックのリクエストが既に記録されているはず)
Screen Shot 2018-03-16 at 11.04.10 AM.png


ロードバランサ経由でアクセスしてみる

DetailsタブからTarget Group Nameのリンクをクリック
Screen Shot 2018-03-16 at 11.07.08 AM.png

DescriptionタブからLoad balancerのリンクをクリック
Screen Shot 2018-03-16 at 11.07.31 AM.png

DNS nameにあるドメインにブラウザでアクセスする
Screen Shot 2018-03-16 at 11.01.16 AM.png

以下の様な画面が表示される
Screen Shot 2018-03-16 at 11.01.58 AM.png


アプリケーションを更新してデプロイしてみる


Task Definitionの新しいrevisionを作成する


Serviceに現在紐付いているTask definitionのリンクをクリックする
Screen Shot 2018-03-16 at 11.11.37 AM.png


Create new revisionをクリックする
Screen Shot 2018-03-16 at 11.12.33 AM.png


下の方にあるContainer Definitionsの中のsample-appをクリックする
Screen Shot 2018-03-16 at 11.13.13 AM.png


中盤にあるENVIRONMENTの中のCommandで、書き出しているHTMLの定義を適当に変更し、Updateをクリックする
Screen Shot 2018-03-16 at 11.16.37 AM.png


戻ったら、右下のCreateをクリックする
Screen Shot 2018-03-16 at 11.17.11 AM.png


Serviceを今作成したTask Definitionで更新する


新しいrevisionが作成できたら、ActionsのメニューからUpdate Serviceをクリックする
Screen Shot 2018-03-16 at 11.17.45 AM.png


Serviceの更新画面に移るので、チュートリアルで作成したService, Clusterが選択されていることを確認して、Next stepをクリックする
Screen Shot 2018-03-16 at 11.19.04 AM.png


特に変更しないので、Next stepをクリックする
Screen Shot 2018-03-16 at 11.19.15 AM.png


特に変更しないので、Next stepをクリックする
Screen Shot 2018-03-16 at 11.19.26 AM.png


Update Serviceをクリックする
Screen Shot 2018-03-16 at 11.19.36 AM.png


更新が完了したら、View Serviceをクリックする
Screen Shot 2018-03-16 at 11.19.49 AM.png


Deploymentsのタブが開き、新しいTaskのデプロイがスケジュールされていることを確認する
Screen Shot 2018-03-16 at 11.20.10 AM.png


しばらく更新を続けていると、PRIMARY側のRunning countが1になる
Screen Shot 2018-03-16 at 11.22.12 AM.png


改めてLoad balancerにアクセスすると、先程更新したアプリケーションが表示されることを確認
Screen Shot 2018-03-16 at 11.22.30 AM.png


Eventsタブを見ると、古いTaskはまだ稼働中だがLoad balancerからは切り離されconnection drainingをしていることが確認できる
Screen Shot 2018-03-16 at 11.24.09 AM.png


クリーンアップ


以下にアクセスし、作成したClusterをクリックする
https://console.aws.amazon.com/ecs/home?region=us-east-1#/clusters
Screen Shot 2018-03-16 at 11.28.55 AM.png


右上のDelete Clusterをクリックし、モーダルの中身を確認しDeleteをクリックする
Screen Shot 2018-03-16 at 11.29.39 AM.png


徐々に削除が進んでいくので、そのまま完了を見守る
Screen Shot 2018-03-16 at 11.30.02 AM.png


以下のようになれば完了。
Screen Shot 2018-03-16 at 11.35.32 AM.png


[オプション]CloudWatch LogsのLog Streamを削除
(少量なため毎月の無料枠で十分賄えるが、気になる方は削除するのをお勧め)
https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logStream:group=/ecs/first-run-task-definition

上のリンクを開いたら、2つのLog Streamsを選択する。
Screen Shot 2018-03-16 at 6.06.11 PM.png

Delete Log Streamをクリックし、Yes, Deleteをクリックして削除する。
Screen Shot 2018-03-16 at 6.06.21 PM.png

以下の様になれば完了。
Screen Shot 2018-03-16 at 6.06.40 PM.png


お疲れ様でした

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up