中間集計結果 - JUCE · 可視化 ②ナンバリングのWeb掲載による 可視化 シミュレーション ④①から③以外の利活用 ⑤可視化にICTを利活用していない
AWS Codeシリーズを利用した パイプラインの自動化入門 · Visual...
Transcript of AWS Codeシリーズを利用した パイプラインの自動化入門 · Visual...
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Atsushi Fukui
DevOps Specialist Solutions Architect, Amazon Web Services Japan K.K.
3-H1-1-15
AWS Codeシリーズを利用した
パイプラインの自動化入門
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
自己紹介❖名前
❖ 福井 厚(ふくい あつし) fatsushi@
❖所属❖ アマゾン ウェブ サービス ジャパン株式会社
❖ 技術統括本部レディネスソリューション部
❖ ソリューション アーキテクトDev&Opsスペシャリスト
❖前職❖ エンタープライズ アプリケーション開発コンサルタント
❖好きなAWSサービス❖ AWS Code シリーズ、AWS Cloud9、Amazon ECS/Fargate/EKS、AWS Lambda
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
なぜDevOpsなのか?
AmazonのDevOps ストーリー
AWS Code シリーズ
AWS Codeシリーズを利用したパイプラインの自動化
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
なぜDevOpsなのか?
ソフトウェア開発は高速化している
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
なぜ DevOps なのか?
5x 変更による失敗率の低下
440xコミットからデプロイまでの速度
46xより頻繁なデプロイメント
44%新機能の開発に費やす時間の増加
Source: Puppet 2017 State of DevOps Report
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DevOpsとは何か?
• カルチャーと哲学
• プラクティス
• ツール
Culture
PracticesTools
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
カルチャー
• DevとOpsを一緒に
• 壁をつくらない
• 責任をチームで共有
• オーナーシップを持つ
• 見える化とコミュニケーション
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DevOpsのプラクティス
マイクロサービス
モノリシックなアプリケーション アーキテクチャから多くの独立したサービスへ
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DevOpsのプラクティス
• 継続的インテグレーション
• 継続的デリバリー&デプロイメント
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DevOpsのプラクティス
Infrastructure as code
• コードによってAWSリソースをモデル化
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DevOpsのプラクティス
• モニタリングとロギング
• メトリックスとログをトラックして分析
• インフラストラクチャとアプリケーションのリアルタイムなフォーマンスを理解する
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
信頼性
DevOpsのメリット
スピードスケール
迅速なデリバリーコラボレーションの改善
セキュリティ
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AmazonのDevOpsストーリー
Amazonの開発の歴史をふりかえる
https://secure.flickr.com/photos/pixelthing/15806918992/
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazonにおける開発の変遷: 2001–2009
2001 2009
モノリシックアプリケーション +チーム
マイクロサービス + 2ピザチーム
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
モノリシックなアーキテクチャの問題点
密結合
メンテナンスと維持が難しい• ソースコードが複雑に絡み合い、マージ一つでも一苦労
ビルドやテストがとにかく時間がかかる
デプロイがボトルネック• デプロイが一大イベントとなる
1つのプロセスで提供される
スケールが難しい
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• 単一目的のサービス
• HTTPSのAPIのみによる通信
• お互いをブラックボックスに
• マイクロサービス
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• 2ピザ チーム
• 全ての所有権
• 全ての説明責任
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2ピザチームの働き方
• ”サービスチーム”と呼ぶ
• サービスを所有し、構築する:• プロダクトプランニング(ロードマップ)
• 開発
• 運用/カスタマーサポート
• “You build it, you run it”
• 大きな組織の一部分を構成する (Amazon.com、AWS、 Primeなど)
さらにスピードアップするためにソフトウェアリリースプロセスの自動化ツールを開発
https://secure.flickr.com/photos/lindseygee/5894617854/
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
自動化されたアクションと遷移、チェックインから本番環境へ
開発のメリット
• より高速
• より安全
• 単純化と標準化
• プロセスの見える化
パイプライン
Where Do You
?
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• 他のシステムとの統合テスト
• ロードテスト• UIテスト• 侵入テスト
リリースとモニタのフェーズ
Source Build Test Deploy Monitor
• .javaファイルなどのソースコードをチェックイン
• 新しいコードのピアレビュー
• コードのコンパイル
• ユニットテスト• スタイルチェッ
カー• コードメトリッ
ク• コンテナイメー
ジの作成
• 本番環境にデプロイ
• 異常なアクティビティやエラーを素早く検知するために本番環境のコードをモニタリング
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Codeシリーズ
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Code サービス
Source Build Test Deploy Monitor
AWS CodeBuild
+ Third Party
ソフトウェア リリース ステップ
AWS CodeCommit AWS CodeBuild AWS CodeDeploy
AWS CodePipeline
AWS
CodeStar
AWS X-Ray
Amazon
CloudWatch
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
コードのバージョンを管理する
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
セキュアでスケーラブルなマネージドGitソース管理
スタンダードなGit ツールが利用可能
Visual StudioやEclipseなど普段利用しているIDEから接続可能
Amazon S3のスケーラビリティ、可用性、堅牢なストレージを利用
カスタマ特有のキーを使用した暗号化
レポジトリサイズの上限なし
AWS CodeCommit
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeCommit
Git pull/pushAWS CodeCommit
GitオブジェクトはAmazon S3
GitインデックスはAmazon DynamoDB
暗号化キーはAWS KMSに保存
SSH or HTTPS
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
リポジトリのコンテンツ参照
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
コミット間の差分表示
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
コミット グラフの表示
Commit Visualizer を選択
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
プルリクエスト機能• リポジトリのユーザに対して、プルリクエストを起点としたコードに関
する議論やコミュニケーションの機会を提供できるようになった
• CodeCommitの仕組みの中でコードレビューを実施したり、変更箇所を精査することが可能に。結果として品質改善に繋げることができる
アプリケーションをビルドしてテストする
https://secure.flickr.com/photos/spenceyc/7481166880
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
完全なマネージドのビルドサービスでソースコードのコンパイル、実行、テスト、ソフトウェアパッケージの生成をサポート
継続的なスケールと同時複数ビルドの実行
Dockerイメージによってニーズにマッチするカスタムなビルド環境を構築可能
利用したコンピュータ リソース/分のみの支払い
CodePipelineやJenkinsとの統合が可能
AWS CodeBuild
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeBuild のコンセプト
1. CodeBuild にビルド プロジェクトを作成
2. AWS CodeBuild はビルド プロジェクトに基づいてビルド環境を構築
3. AWS CodeBuildはソースコードをダウンロード
4. ビルドのアウトプットをS3へアップロード
5. ビルド実行中、AWS CodeBuild とAWS CloudWatch Logs に情報を送信
6. ビルド実行中、AWS CodeBuild コンソール、AWS CLI、AWS SDK、AWS APIでビルド情報を取得
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
version: 0.1
environment_variables:plaintext:JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"
phases:install:commands:- apt-get update -y- apt-get install -y maven
pre_build:commands:- echo Nothing to do in the pre_build phase...
build:commands:- echo Build started on `date`- mvn install
post_build:commands:- echo Build completed on `date`
artifacts:type: zipfiles:- target/messageUtil-1.0.jar
discard-paths: yes
buildspec.yml の例
• ビルドの各フェーズで利用される環境変数
• 各フェースで実行するコマンドの指定• “insutall”では環境を準備するた
めのパッケージのインストールやコマンドの実行など
• ”pre build“では構文チェックやコマンドの実行など
• “build”ではビルドツールやコマンドの実行など
• “post build”ではテスト実行やレポジトリへのコンテナイメージの配布
• アーティファクトを作成しS3に保存
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ローカル環境でのテストとデバッグをサポート
• AWS CodeBuildのローカル エージェントを利用してCodeBuildのローカル環境でのテストとデバッグが可能
• ローカルでのCodeBuild環境のシミュレートが可能になり、buildspecファイル上のコマンドや設定のトラブルシュートが容易
• 詳細は下記のBlog記事を参照くださいhttps://aws.amazon.com/blogs/devops/announcing-local-build-support-for-aws-codebuild/
アプリケーションをデプロイする
https://secure.flickr.com/photos/simononly/15386966677
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あらゆるインスタンスに対するコードのデプロイメントを自動化
アプリケーションの複雑なアップデートに対処
アプリケーションのデプロイ中のダウンタイムを回避
失敗を検知したら自動的にロールバック
言語やオペレーティングシステムに依存せずに、Amazon EC2やオンプレミスサーバーにデプロイ
AWS Lambdaへのカナリア デプロイをサポート
AWS CodeDeploy
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeDeploy ワークフロー
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
version: 0.0os: linuxfiles:
- source: /destination: /var/www/html
permissions:- object: /var/www/html
pattern: “*.html”owner: rootgroup: rootmode: 755
hooks:ApplicationStop:
- location: scripts/deregister_from_elb.shBeforeInstall:
- location: scripts/install_dependencies.shApplicationStart:
- location: scripts/start_httpd.shValidateService:
- location: scripts/test_site.sh- location: scripts/register_with_elb.sh
• ELBへのインスタンスの追加と削除
• 依存パッケージのインストール• Apacheの起動• デプロイの成功を確認
• アプリケーションファイルと設定ファイルをそれぞれのディレクトリに送信
• 特定のディレクトリとファイルのアクセス許可を設定
appspec.ymlの例
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
v2 v2 v2 v2 v2 v2
1つずつ
半分ずつ
すべて一度に
v2 v2 v2 v1 v1 v1
v2 v1 v1 v1 v1 v1 エージェント
開発デプロイグループ
または本番デプロイグループ
デプロイの作業量とグループの選択
エージェント
エージェント エージェント エージェント
エージェント エージェント エージェント
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Lambda
• AWS Lambda
• カナリア
• 最初の増分でトラフィックの指定パーセントを移行し、指定された時間経過後に残りを移行
• リニア
• 最初の増分でトラフィックの指定パーセントを移行、指定した分数経過後に指定パーセント増加を繰り返す
Version 2
Version 1
alias
Event
Source
10%
パイプラインによる展開
https://www.flickr.com/photos/seattlemunicipalarchives/12504672623/
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アプリケーションのすばやく信頼できるアップデートを可能にする継続的デリバリサービス
ソフトウェアリリースプロセスのモデル化と見える化
コードが変更されるたびにコードをビルド、テスト、デプロイ
サードパーティツールやAWSとの統合
AWS CodePipeline
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Source
SourceGitHub
Build
JenkinsOnEC2Jenkins
Deploy
JavaAppElastic Beanstalk
パイプラインステージ
アクション
トランジション
MyApplication
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Build
AWS CodeBuildAWS CodeBuild
Staging-Deploy
JavaAppElastic Beanstalk
Prod-Deploy
JavaAppElastic Beanstalk
QATeamReviewManual Approval
マニュアル承認Review
MyApplication
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
9. ビルドアーティファクトを取得
Source
SourceCodeCommit
Build
JenkinsOnEC2CodeBuild
Deploy
JavaAppCodePipeline
ソースアーティファクト
S3
ビルドアーティファクト
S
5. ソースアーティファクトを取得
1. 変更を取得
6. ビルドアーティファクトを格納
3. ジョブをポーリング
4. ジョブを承認
7. 成功を通知
8. CodePipelineでイメージを更新
MyApplication
AWS CodeCommit
Amazon ECS
Amazon ECR
AWS CodeBuild
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeStar
• AWS上でのアプリケーションの素早い開発、ビルド、デプロイ
• 数分でAWS上での開発を開始
• 安全にチームを横断して作業
• ソフトウェア デリバリーを容易に管理
• 多様なプロジェクトテンプレートから選択
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Codeシリーズを利用した
パイプラインの自動化
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Demo
AWS CodeStarによるCI/CD環境の構築
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
EC2インスタンスのための継続的デリバリー(CodeDeploy)
AWS CodeCommit AWS
CodeBuild
Source Repository Build Deploy
Or
AWS Cloud9
AWS CodeStar
Author
AWS CodePipeline
Monitor
AWS X-Ray
And/ or Amazon
CloudWatch
AWS CodeDeployAmazon
EC2
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
EC2インスタンスのための継続的デリバリー(Elastic Beanstalk)
AWS CodeCommit AWS
CodeBuild
Source Repository Build
Or
AWS Cloud9
AWS CodeStar
Author
AWS CodePipeline
Monitor
AWS X-Ray
And/ or Amazon
CloudWatch
Amazon EC2
AWS Elastic Beanstalk
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
サーバーレスアプリケーションのための継続的デリバリー
AWS CodeCommit
AWS CodeBuild
Source Repository Build Deploy
Or
AWS Cloud9
AWS CodeStar
AWS Lambda
Author
AWS CodePipeline
Monitor
AWS X-Ray
And/ or Amazon
CloudWatch
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
コンテナのための継続的デリバリー
AWS CodeCommit
AWS CodeBuild
Amazon ECR
Amazon ECS/Fargate
Source repository Build Deploy
Or Or
AWS CodePipeline
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
価格AWS CodeStar
無料。作成したEC2インスタンスやパイプラインなどの課金が発生。AWS CodeCommit
$1 / アクティブユーザー/ 月 (最初の5ユーザーは無料)AWS CodePipeline
$1 / アクティブなパイプライン / 月 (最初の1つは無料)AWS CodeDeploy
Amazon EC2へのデプロイは無料$0.02 / オンプレミスサーバーへの更新
AWS CodeBuild分単位の課金。build.general1.smallで100分/月の無料枠
Compute Instance
Type
Memory(GB) vCPU Price per build minute
($)
Small 3 2 0.005
Medium 7 4 0.010
Large 15 8 0.020
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
まとめ
• DevOpsを実現するカルチャー、プラクティス、ツール
• 継続的インテグレーション/継続的デリバリーは必須
• AWS Codeシリーズを利用して、フルマネージドな環境でパイプラインの自動化を容易に実現!
• 付加価値を伴わない重たい作業はマネージドサービスに任せて、価値を生む作業に集中する!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.