Vous êtes sur la page 1sur 24

CI/CD  on  AWS

Deploy  Everything  All  Of  The  Time

Leo  Zhadanovsky
Principal  Solutions  Architect,  AWS
April  12th,  2016

©  2016,  Amazon  Web  Services,  Inc.  or  its  Affiliates.  All  rights  reserved.
Why  does  DevOps  matter?

• High-­performing   IT  organizations   deploy  30x  more  


frequently  with  200x shorter  lead  times;;  they  have  60x
fewer  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:  p uppet  labs  2 015  S tate  o f  Devops Report)


https://puppetlabs.com/sites/default/files/2015-­state-­of-­devops-­report.pdf
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
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
SOURCE  CODE
REPOSITORY

SUBMIT
CODE CLOUDFORMATION
DOCS

CONTINUOUS  
INTEGRATION  SERVER
CODE
CODE  QUALITY
RECURRENT
FETCH BINARIES
AMIS  or  CONTAINERS
TESTS
BUILDS &  PACKAGES
SCHEDULE BUILD  OUTPUT
BUILD
DEVELOPER
PROJECT  MANAGEMENT
SERVER DEV  FACING  
PICK NOTIFICATIONS
TEST
TASKS
RESULTS
Components  of  traditional  CI/CD  on  AWS

Deployment Git Repository CI  Software Project  Management   Build  


Software EC2  Instance EC2  Instance Software Artifacts
On  Laptop EC2  Instance S3  Bucket
AWS  code  services

AWS  CodeCommit AWS  CodePipeline AWS  CodeDeploy


Cloud  software  development  lifecycle

Code Build Test Deploy Provision Monitor

?
AWS  Elastic  Beanstalk

AWS  OpsWorks

AWS   Amazon  
CloudFormation CloudWatch
CodeCommit:  source  control
Private  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
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
CodePipeline:  continuous  delivery
Customizable  release  automation,  with  integrated  build  and  test

Model  and  visualize  custom  release  workflow


(source   è build   è beta   è gamma  è prod)
Automate  builds,  tests,  and  deployments
Integrate  with  third-­party  and  custom  tools
Deployment
Coordinate  software  updates  to  fleets  of  EC2  instances

Rolling  updates  for  no  downtime


Deployment  health  checks  and  easy  rollback
Auto  Scaling  integration
Works  with  any  application
Reuse  existing  setup  tools
(Bash,  Powershell,  Chef,  Puppet…)
Cloud  software  development  lifecycle

Code Build Test Deploy Provision Monitor

AWS  Elastic  Beanstalk

CodeCommit CodePipeline AWS  OpsWorks

CodeDeploy CloudFormation CloudWatch


Components  of  CI/CD  with  AWS  Code  Services

AWS   Git Repository AWS   CI  Software* Project  Management   Build  


CodePipeline CodeCommit CodeDeploy EC2  Instance Software Artifacts
EC2  Instance S3  Bucket
DevOps  Partner  Solutions
Solutions  vetted  by  the  AWS  Partner  Competency  Program
Continuous  
Configuration  
Integration  &  
Management
Delivery

Rapidly  and  reliably  build,   test  and  release  your  applications,   Treat  your  infrastructure  as  code,  manage  container,  
while  improving  quality  and  reducing  time  to  market operating  system,  and  application   configurations

https://aws.amazon.com/s olutions/partners/dev-­ops /
Today’s  demo

Commit

Develop AWS  CodeCommit Build

AWS  CodePipeline

Monitor Amazon Test


CloudWatch

AWS  CodeDeploy

Deploy
Application  architecture

ELB  load  balancer

Jenkins   WordPress servers WordPress servers


(on  EC2  instance)
Auto Scaling group

RDS  MySQL  primary RDS  MySQL  standby


Availability Zone A Availability Zone B
Deployment  overview
9.  L oad  test  is  run  
on  the  staging  
Auto  S caling  
S3  bucket group,  p roduction  
Developer deploy  is  triggered

AWS  CodePipeline 10.  Deployment  is  


1.  P ush  code  to   AWS  CodeDeploy marked  in  
NewRelic
remote  repository
4.  Jenkins  p olls   5.  Jenkins   6.  S ervers  a re   7.  S ervers   8.  CodeDeploy is  
CodePipeline for   runs  tests  o n   notified  o f   download   notified  o f  success  
new  a ctivity code  a nd   deployment and  install or  failure
notifies  
2.  CodePipeline polls   CodePipeline
GitHub for  n ew   of  results
commits

3.  CodePipeline
pulls  n ew  commits
into  ZIP  file  in  S 3 Jenkins   WordPress  servers
(on  EC2  instance)
(Auto  Scaled)
CodeDeploy lifecycle   events
0.  Instance  is  n otified  o f  n ew  
deployment

AWS  CodeDeploy 2.  DownloadBundle


7.  V alidateService
CodeDeploy is  n otified  o f  
successful  d eployment
5.  AfterInstall
• Update  p ermissions
• Download  config/creds 3.  BeforeInstall
• Mark  deployment  in  New   • Delete  o ld  version
S3  bucket Relic • Install  d ependencies
• Install  New  Relic  
1.  ApplicationStop agents
• Deregister  from  load  
balancer
• Stop  server

6.  ApplicationStart
Target  Instance
• Start  server 4.  Install
Elastic  Load   • Register  with  load  
balancer
Balancer
CodeDeploy default  deployment  configs

AllAtOnce

HalfAtATime

OneAtATime
CodeDeploy custom  deployment  configs

HOST_COUNT = 10 FLEET_PERCENT =  80


No  less  than  10 hosts  should  be   No  less  than  80% of  hosts  should  
healthy  during  deployment,   be  healthy  during  deployment
regardless  of  the  number  of  
instances
Failed  deployments  in  CodeDeploy

Deploy  
version  1.5 version  1.4

Deploy O Deploy O Deploy O


to   K Yes to   K Yes to   K Yes
Done
? ? ?
No No No
Deployment  failed

Recover  from  a  failed  or  canceled  


deployment  by  creating  a  new  
deployment  of  the  previous  version  
Live  demo

Vous aimerez peut-être aussi