CI CD On AWS
CI CD On AWS
Delivery/Deployment on AWS
Shiva N ([email protected])
AWS Solution Architect
Version 1.0
DEPLOYMENTS AT
AMAZON.COM
Package
Config Builder
Install
Create AMIs
Code Push
Config Test Env
Tests
Version Deploy Staging Env
CI Server
Commit to Control Get / Server
Git/master Pull Prod Env
Dev Code
Distributed Builds
Run Tests in parallel
Package
Config Builder
Install
Create AMIs
Code Push
Config Test Env
Tests
Version Deploy Staging Env
CI Server
Commit to Control Get / Server
Git/master Pull Prod Env
Dev Code
Distributed Builds
Run Tests in parallel
Test Env
Version Control Artifact Repository
DR Env
CloudFormation
Automate
Write Build Validate Deploy
Infra Code
Deploymen
Infras
Prod Env
AMIs Templates t
IT Ops
Infrastructure Deploy infrastructure
only
AMI
v
https://secure.flickr.com/photos/jasoneppink/499531891
HOST v
SERVICE
METRICS METRICS
EXTERNAL SITE
LOG ANALYSIS
METRICS
v
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Elastic BeanStalk
• Opsworks
• Cloudformation
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
v
https://secure.flickr.com/photos/simononly/15386966677
Delivery approaches
v
• How are we going to deliver our code?
• File shipping:
• Binaries (.rpm, .msi. .exe, .deb,
.conf…)
• As an AMI:
• Bundle one or more of the above
into an AMI
• Which method do you choose?
• How fast do we need to do this?
• Across how many instances?
• How do we roll back (or forward)?
AMI Deployment Method - Building
v
Delivery approaches…
v
Fully Functional AMI OS-Only AMI
ELB
EC2 Instances
ELB ELB
ELB ELB
ELB ELB
ELB ELB
ELB ELB
Auto Scaling
Group
V1
Amazon
Relational
Database Service
(RDS)
Red-Black Deployment
v
ELB
UAT
Amazon
Relational
Database Service
(RDS)
Red-Black Deployment
v
ELB
Amazon
Relational
Database Service
(RDS)
Red-Black Deployment
v
ELB
Auto Scaling
Group
V2
Amazon
Relational
Database Service
(RDS)
HOST v
SERVICE
METRICS METRICS
EXTERNAL SITE
LOG ANALYSIS
METRICS
v
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Elastic BeanStalk
• Opsworks
• Cloudformation
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
Deployment and Management
AWS Elastic AWS OpsWorks v
AWS DIY /
Beanstalk CloudFormation On Demand
Automated resource DevOps framework for Templates to deploy & DIY, on demand
management – web application lifecycle update infrastructure resources: EC2, S3,
apps made easy management and as code custom AMI’s, etc.
automation
Convenience Control
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Elastic BeanStalk
• Opsworks
• Cloudformation
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
AWS Elastic Beanstalk (EB)
• Easily deploy, monitor, and scale three-tier vweb applications
and services.
• Infrastructure provisioned and managed by EB – but you
maintain complete control.
• Preconfigured application containers that are easily
customizable.
• Support for these platforms:
HTTP server
• Elastic Beanstalk configures
each EC2 instance in your
Application server
environment with the
components necessary to run
Language interpreter
applications for the selected
platform
Operating system
• No more worrying about
Host
logging into instances to install
and configure your application
stack
Application versions and saved configurations
v
Application versions
All versions are stored durably in
Amazon S3. Code can also be
pushed from a Git repository!
Saved configurations
Save these for easy duplication for A/B
testing or non-disruptive deployments
Deployment options
v
1. Via the AWS Management Console
01 Region
Follow the prompts to configure the Create the resources and launch the
03 06
environment application
$ eb create
Example: CLI workflow
v
commands:
0_newrelic_command:
command: "touch /tmp/$(date '+%F.%T.%N').newrelic_command_0"
1_configure_new_relic_key:
command: nrsysmond-config --set license_key=<Your key here>
1a_newrelic_command:
command: "touch /tmp/$(date '+%F.%T.%N').newrelic_command_1a"
2_start_new_relic:
command: "/etc/init.d/newrelic-sysmond start"
2a_newrelic_command:
command: "touch /tmp/$(date '+%F.%T.%N').newrelic_command_2a"
Iterate on application architecture
v
Add additional resources to your environments using ebextensions:
Add other components such as: Resources:
MyElastiCache:
• In-memory caching (Amazon ElastiCache Redis and Type: AWS::ElastiCache::CacheCluster
Memcached) Properties:
CacheNodeType:
• Amazon SQS Fn::GetOptionSetting:
• Amazon CloudFront OptionName : CacheNodeType
DefaultValue: cache.m1.small
NumCacheNodes:
Fn::GetOptionSetting:
OptionName : NumCacheNodes
DefaultValue: 1
Engine:
Fn::GetOptionSetting:
OptionName : Engine
DefaultValue: memcached
Zero-downtime deployments
v
Swap URLs
1. Create a new environment for an existing application
3. Use the “Swap URLs” feature to transition users to the new production
environment
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Elastic BeanStalk
• Opsworks
• Cloudformation
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
AWS OpsWorks architecture
v
Command
JSON
Command
Log+Status
EC2 instance
5
5
Chef integration
v
stack
monitoring
Infrastructure Provisioning
• Region
Monitoring
• Availability Zone
AWS • Logs
• Operating system
• Monitor
• Keys OpsWorks
Instance lifecycle commands
v
Setup event
v
https://secure.flickr.com/photos/macwagen/94975613
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Elastic BeanStalk
• Opsworks
• Cloudformation
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
Amazon CloudFormation
v
• Infrastructure as Code
• Integrates with version control
• JSON format
• Templates
• Stacks
• Supports all AWS resource types
AWS CloudFormation
AWS CloudFormation: Model Your App
v
• Document, version control, and share your applications and
infrastructure as a JSON document
• Provision app and other AWS resources (VPC, DynamoDB, etc) from a
template
• Repeatable, reliable deployments for test/dev/prod in any AWS
Region
AWS CloudFormation: Application stack
example (continue) v Use the version
control system of
your choice to store
Build out multiple
and track changes to
environments, such Dev this template
as for Development, Git
Test, and Production Test Subversion
using the template Mercurial
Prod
Template File
Defining Stack
Push images
Customer
Run task
Customer
Describe cluster
Customer
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Cloudformation
• Elastic BeanStalk
• Opsworks
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
ALM | What is CodeCommit?
v
A secure, highly scalable, managed source
control service that hosts private Git repositories.
v
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Cloudformation
• Elastic BeanStalk
• Opsworks
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
ALM | What is CodePipeline?
v
A continuous delivery and release automation
service that aids smooth deployments.
v
Agenda
• Intro to Continuous Integration and Continuous Deployment/Delivery
v
(CI-CD)
• CD Strategies
• CI-CD on AWS
– Application Management
• Cloudformation
• Elastic BeanStalk
• Opsworks
• EC2 Container Service (ECS)
– Application Lifecycle Management
• Code Commit
• Code Pipeline
• Code Deploy
Code Deploy
v
95
Using AWS CodeDeploy
96
Using AWS CodeDeploy
97
Using AWS CodeDeploy
98
Using AWS CodeDeploy
• Review your settings and deploy.
99
https://secure.flickr.com/photos/dullhunk/202872717/