ci/cd on aws: deploy everything all the time

24
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Leo Zhadanovsky Principal Solutions Architect, AWS April 12 th , 2016 CI/CD on AWS Deploy Everything All Of The Time

Upload: doandieu

Post on 03-Jan-2017

227 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CI/CD on AWS: Deploy Everything All the Time

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Leo ZhadanovskyPrincipal Solutions Architect, AWS

April 12th, 2016

CI/CD on AWSDeploy Everything All Of The Time

Page 2: CI/CD on AWS: Deploy Everything All the Time

Why does DevOps matter?

• High-­performing IT organizations deploy 30x more frequently with 200x shorter lead times;; they have 60xfewer failures and recover 168x faster.

• Lean management and continuous delivery practices create the conditions for delivering value faster, sustainably.

• High performance is achievable whether your apps are greenfield, brownfield, or legacy.

(source: puppet labs 2015 State of Devops Report)https://puppetlabs.com/sites/default/files/2015-­state-­of-­devops-­report.pdf

Page 3: CI/CD on AWS: Deploy Everything All the Time

What are CI and CD?

• Continuous Delivery• A software engineering approach in which teams keep producing valuable software in short cycles and ensure that the software can be reliably released at any time

• Continuous Integration• The practice, in software engineering, of merging all developer working copies to a shared mainline several times a day

Page 4: CI/CD on AWS: Deploy Everything All the Time

What are CI and CD?

• Changes to code automatically deployed to mainline branch• After passing unit and mock tests

• Makes changes to code and deployments iterative, not monolithic

• Bugs are detected quickly• Helps automate deployments• Allows rapid development and deployment

Page 5: CI/CD on AWS: Deploy Everything All the Time

SOURCE CODEREPOSITORY

PROJECT MANAGEMENTSERVER

CONTINUOUS INTEGRATION SERVER

DEVELOPER

PICKTASKS

SUBMITCODE

SCHEDULEBUILD

RECURRENTBUILDS

CODEFETCHCODE QUALITY

TESTS

TESTRESULTS

BUILD OUTPUT

DOCS

BINARIES& PACKAGES

DEV FACING NOTIFICATIONS

CLOUDFORMATION

AMIS or CONTAINERS

Page 6: CI/CD on AWS: Deploy Everything All the Time

Components of traditional CI/CD on AWS

Git RepositoryEC2 Instance

CI SoftwareEC2 Instance

Project Management Software

EC2 Instance

Build ArtifactsS3 Bucket

DeploymentSoftwareOn Laptop

Page 7: CI/CD on AWS: Deploy Everything All the Time

AWS code services

AWS CodeCommit AWS CodePipeline AWS CodeDeploy

Page 8: CI/CD on AWS: Deploy Everything All the Time

Cloud software development lifecycle

MonitorProvisionDeployTestBuildCode

AWS Elastic Beanstalk

AWS OpsWorks

Amazon CloudWatch

AWS CloudFormation

?

Page 9: CI/CD on AWS: Deploy Everything All the Time

CodeCommit: source controlPrivate Git repositories hosted on Amazon S3

Full Git compatibility (use with existing tools)All the benefits of the cloud(scalable, durable, reliable, low pay-­as-­you-­go pricing)No size limits on repositories (store binary files)Online web console

Page 10: CI/CD on AWS: Deploy Everything All the Time

CodeCommit: same Git experience

$ git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/aws-cli

Cloning into 'aws-cli'...

Receiving objects: 100% (16032/16032), 5.55 MiB | 1.25 MiB/s, done.

Resolving deltas: 100% (9900/9900), done.

Checking connectivity... done.

$ nano README.rst

$ git commit -am 'updated README'

[master 4fa0318] updated README

1 file changed, 1 insertion(+)

$ git push

Counting objects: 3, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (3/3), done.

Writing objects: 100% (3/3), 297 bytes | 0 bytes/s, done.

Total 3 (delta 2), reused 0 (delta 0)

remote:

To https://git-codecommit.us-east-1.amazonaws.com/v1/repos/aws-cli

4dacd6d..4fa0318 master -> master

Page 11: CI/CD on AWS: Deploy Everything All the Time

CodePipeline: continuous deliveryCustomizable release automation, with integrated build and test

Model and visualize custom release workflow(source è build è beta è gamma è prod)Automate builds, tests, and deploymentsIntegrate with third-­party and custom tools

Page 12: CI/CD on AWS: Deploy Everything All the Time

DeploymentCoordinate software updates to fleets of EC2 instances

Rolling updates for no downtimeDeployment health checks and easy rollbackAuto Scaling integrationWorks with any applicationReuse existing setup tools(Bash, Powershell, Chef, Puppet…)

Page 13: CI/CD on AWS: Deploy Everything All the Time

Cloud software development lifecycle

MonitorProvisionDeployTestBuildCode

AWS Elastic Beanstalk

AWS OpsWorks

CloudWatchCloudFormationCodeDeploy

CodeCommit CodePipeline

Page 14: CI/CD on AWS: Deploy Everything All the Time

Components of CI/CD with AWS Code Services

CI Software*EC2 Instance

Project Management Software

EC2 Instance

Build ArtifactsS3 Bucket

Git RepositoryCodeCommit

AWS CodePipeline

AWS CodeDeploy

Page 15: CI/CD on AWS: Deploy Everything All the Time

DevOps Partner SolutionsSolutions vetted by the AWS Partner Competency Program

Continuous Integration & Delivery

Rapidly and reliably build, test and release your applications, while improving quality and reducing time to market

Configuration Management

Treat your infrastructure as code, manage container, operating system, and application configurations

https://aws.amazon.com/solutions/partners/dev-­ops /

Page 16: CI/CD on AWS: Deploy Everything All the Time

Today’s demo

Develop

Commit

Build

Test

Deploy

Monitor

AWS CodeCommit

AWS CodePipeline

AWS CodeDeploy

AmazonCloudWatch

Page 17: CI/CD on AWS: Deploy Everything All the Time

Application architecture

Jenkins (on EC2 instance)

WordPress servers

Availability Zone A Availability Zone B

WordPress servers

Auto Scaling group

RDS MySQL primary RDS MySQL standby

ELB load balancer

Page 18: CI/CD on AWS: Deploy Everything All the Time

Developer S3 bucket

Jenkins (on EC2 instance)

1. Push code to remote repository

2. CodePipeline polls GitHub for new commits

3. CodePipelinepulls new commitsinto ZIP file in S3

5. Jenkins runs tests on code and notifies CodePipelineof results

7. Servers download and install

AWS CodeDeploy

6. Servers are notified of deployment

4. Jenkins polls CodePipeline for new activity

WordPress servers(Auto Scaled)

8. CodeDeploy is notified of success or failure

AWS CodePipeline

Deployment overview9. Load test is run on the staging Auto Scaling group, production deploy is triggered

10. Deployment is marked in NewRelic

Page 19: CI/CD on AWS: Deploy Everything All the Time

CodeDeploy lifecycle events

AWS CodeDeploy

Elastic Load Balancer

Target Instance

S3 bucket1. ApplicationStop

• Deregister from load balancer

• Stop server

3. BeforeInstall• Delete old version• Install dependencies• Install New Relic

agents

2. DownloadBundle

4. Install

5. AfterInstall• Update permissions• Download config/creds• Mark deployment in New

Relic

6. ApplicationStart• Start server• Register with load

balancer

0. Instance is notified of new deployment

7. ValidateServiceCodeDeploy is notified of successful deployment

Page 20: CI/CD on AWS: Deploy Everything All the Time

CodeDeploy default deployment configs

AllAtOnce

OneAtATime

HalfAtATime

Page 21: CI/CD on AWS: Deploy Everything All the Time

CodeDeploy custom deployment configs

HOST_COUNT FLEET_PERCENT = 80No less than 80% of hosts should be healthy during deployment

No less than 10 hosts should be healthy during deployment, regardless of the number of instances

= 10

Page 22: CI/CD on AWS: Deploy Everything All the Time

Failed deployments in CodeDeploy

Deploy version 1.5

Deployto

OK?

Yes

Deployment failed

Deployto

OK?

YesDeployto

OK?

Yes

No No No

Done

version 1.4

Recover from a failed or canceled deployment by creating a new

deployment of the previous version

Page 23: CI/CD on AWS: Deploy Everything All the Time

Live demo

Page 24: CI/CD on AWS: Deploy Everything All the Time