15
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc. AWS ElasticBeanstalk Docker対応 アマゾン データサービス ジャパン株式会社

AWS ElasticBeanstalk Docker対応 · ElasticBeanstalkのDockerサポート ! ElasticBeanstalkで任意のDockerコンテナを実可能に • Dockerコンテナとして構築できれば任意のDistribution・任意の

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    AWS  ElasticBeanstalkDocker対応

    アマゾン  データサービス  ジャパン株式会社

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    2

    AWS  ElasticBeanstalk:  構築・デプロイの⾃自動化サービス

    Instance

    Amazon  RDSElastic  LoadBalancer

    Instance

    Auto  scaling  GroupCloudWatch

    deploy!WARZIP

    Java Python PHP .NET Ruby nodeJS Docker

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    3

    ElasticBeanstalkの論論理理構成

    Application

      Environment VersionRespositoryURL Environment  Configuration

    Configuration  Template

      EnvironmentURL Environment  Configuration

    WAR/ZIP

    WAR/ZIP

    WAR/ZIP

    WAR/ZIP  Environment

    URL Environment  Configuration

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    4

    ElasticBeanstalkのDockerサポート

    ! ElasticBeanstalkで任意のDockerコンテナを実⾏行行可能に•  Dockerコンテナとして構築できれば任意のDistribution・任意の⾔言語で構築した実⾏行行環境をElasticBeanstalkにデプロイ出来る

    !   さらに、下記のような運⽤用が可能•  ローカルのコンテナ上でコードを開発&テスト•  同じコンテナをElasticBeanstalk上の本番環境にデプロイ

    meets

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    5

    各環境の中には!   ⾃自動で構築されたDocker環境

    •  Load-‐‑‒balanced  /  Single  Instance•  各インスタンスに1つの管理理されたコンテナ

     Application

     Environment URL Environment Configuration

    AWS Management Console

    Admin

    SSH Users

    Developer

    ZIP

    Instance

    Amazon  RDSElastic  LoadBalancer

    Instance

    Auto  Scaling  GroupCloudWatch

    AMI

    Dockerfile

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    6

     Environment

    各インスタンスの中には

    EC2 HM

    AutoScaling

    Nginx (tcp:80)

    Docker (tcp: xxxx)

    コンテナの上げ下げ

    コンテナとの 接続ポートの更新

    コマンド

    各インスタンス ・マネージされたコンテナが1つ ・Host Manager (HM)がコマンドを実行

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    7

    コンテナの設定記述の仕⽅方

    !   次の2種類の記述⽅方式を利利⽤用可能•  Dockerfile

    •  ⼀一般的なコンテナの構築に使われるDockerfile•  AWS特有ではないため、どこでも作成・編集・構築が可能•  コンテナの構築⽅方法を指⽰示するファイルなのでコンテナ起動オプションを指定したい場合は不不⼗十分

    •  Dockerrun.aws.json•  ElasticBeanstalk独⾃自の形式•  使⽤用するコンテナイメージ、コンテナから参照するボリュームなどを指定

    •  コンテナの構築⽅方法⾃自体は指定できない(要Dockerfileと併⽤用)

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    8

    Dockerfileの例例

    !   いわゆる普通のDockerfile•  EXPOSEで指定したポートがnginxとの接続に使われる

    注:nginx経由で外部に開けるポートは1つだけ

    !   その他注意点•  FROMとEXPOSEは必須•  CMDとENTRYPOINTのどちらかは必須

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    9

    Dockerrun.aws.jsonの例例

      プライベートレポジトリを使用する際に必要 S3バケット上に置いた認証情報ファイルを指定

    使用すべきイメージ

    コンテナがEXPOSEするポートを指定 (ElasticBeanstalkが使用するのはContainerPortのみ)

    コンテナにマウントすべき EC2インスタンスのディレクトリを指定

    コンテナ内のログディレクトリを指定

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    10

    デプロイの仕⽅方

    !   デプロイ時のファイル形式も2種類•  単⼀一ファイル

    •  Dockerfile  /  Dockerrun.aws.jsonのみのデプロイの場合•  Pros:  アーカイブを作る必要がなく簡便便•  Cons:  ElasticBeanstalkの環境カスタマイズやリソースファイルのデプロイ等は出来ない

    •  ZIPアーカイブ  /  gitでデプロイ•  Dockerfile  /  Dockerrun.aws.jsonあるいは両⽅方を含むアーカイブ•  Pros:  Dockerfileでイメージを構築して起動オプションを指定して起動したり、環境カスタマイズを⾏行行ったりすることが可能

    •  Cons:  アーカイブを作らないといけない

    柔軟性とコンテナ記述ファイルのバージョン管理も考慮すると gitで管理してgit aws.pushでデプロイがおすすめ

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    11

    デプロイ時の動作  (1/4)

    EC2 HM

    AutoScaling

    Nginx (tcp:80)

    Docker (current, ver 1)

    1. Deploy指示

    VersionRespository

    Version  1

    Version  2

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    12

    デプロイ時の動作  (2/4)

    EC2 HM

    AutoScaling

    Nginx (tcp:80)

    Docker (current, ver 1)

    1. Deploy指示

    Docker (staging, ver 2)

    3. Staging コンテナ作成

    VersionRespository

    Version  1

    Version  2

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    13

    デプロイ時の動作  (3/4)

    EC2 HM

    AutoScaling

    Nginx (tcp:80)

    Docker (old, ver 1)

    1. Deploy指示

    Docker (current, ver 2)

    3. Staging コンテナ作成

    4. Nginx設定変更

    VersionRespository

    Version  1

    Version  2

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    14

    デプロイ時の動作  (4/4)

    EC2 HM

    AutoScaling

    Nginx (tcp:80)

    Docker (current, ver 2)

    VersionRespository

    Version  1

    Version  2

  • © 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

    15

    S3をプライベートレポジトリとして利利⽤用

    Developer

    1. docker push 4. docker pull

    2. deploy

    registry registry

    registry

    registry Docker registry container with AWS credentials

    Region

    app

    app

    app

    registry

    app

    3. docker run registry 5. docker stop registry

    詳細: http://aws.typepad.com/sajp/2014/06/eb-docker-private-repo.html