82
DevOps and AWS Shiva Narayanaswamy Solution Architect

DevOps and AWS

Embed Size (px)

Citation preview

Page 1: DevOps and AWS

DevOps and AWS

Shiva NarayanaswamySolution Architect

Page 2: DevOps and AWS

~11.6sMean time between deployments (weekday)

~1,079Max number of deployments in a single hour

~10,000Mean number of hosts simultaneously receiving a deployment

~30,000Max number of hosts simultaneously receiving a deployment

DEPLOYMENTS AT AMAZON.COM

Page 3: DevOps and AWS

75%Reduction in outages triggered by software deployments since 2006

90%Reduction in outage minutes triggered by software deployments

Business Value of Frequent Deployments

~0.001%Software deployments cause anoutage

Page 4: DevOps and AWS

DevOps Culture

Page 5: DevOps and AWS

Innovation & Stability

Business

Development Operations

Build it faster Keep it stable

Page 6: DevOps and AWS

Continuous Innovation

Business Idea

Implementation

Testing

Release

Customer Feedback

Customer

Page 7: DevOps and AWS

Deploying More Frequently Lowers Risk

Smaller Effort“Minimized Risk”

Frequent Release Events:“Agile Methodology”

Time

Change

Rare Release Events:“Waterfall Methodology”

Larger Effort“Increased Risk”

Time

Change

Page 8: DevOps and AWS

Knowledge is power

RequirementsGathering ReleaseDevelopment

and Check In Test and QA

Some Learning

Lots of Learning

Minimal Learning

Cycle Time

Page 9: DevOps and AWS

Change is inevitable

• Change is the root cause of most outages

• This leaves two approaches:-­ Make it a big deal

-­ Small iterative non events

Page 10: DevOps and AWS

“Do painful things more frequently, so you can make it less painful…”

-­ Adrian Cockcroft, Architect, Netflix

Page 11: DevOps and AWS

Waterfall

Analyze Design Build Test Deploy

AgileSprint

Deploy

Agile-­er

A D B T

Sprint

A D B T D

Sprint Sprint

A D B T D A D B T D

Agile-­er

Dev QA Ops

Dev / QA Ops

Dev/QA/Ops Dev/QA/Ops Dev/QA/Ops

SprintA D B T

Sprint

A D B T

Page 12: DevOps and AWS

DevOps is a Re-Org!-­ Adrian Cockcroft, Architect, Netflix

RE

Page 13: DevOps and AWS

– A philosophy? Cultural change? Paradigm shift ?

– Alignment of development and IT operations with better communication and collaboration ?

– Improvement in software deployment ?– Breaking down the barriers between development and IT operations ?

– Akin to Agile software development applied to infrastructure and IT operations

– Set of tools and processes– It’s all of the above!

Code

Wall

Developer IT Operations

DevOps

Page 14: DevOps and AWS

Business Case Requirements Use Case Features Plan Go to market

Business

Design Code Refactor Unit Test Bug Fix Deliver

Developers(application)

Provision Configure Orchestrate Deploy Report Monitor

IT Operations

Agile Development

DevOps• Continuous Integration• Continuous Deployment• IT Automation• Application Management

• Iterative development• Scrum, sprints, stories• Velocity

BusinessAgility

ITAgility

Business and IT agility

Page 15: DevOps and AWS

Building Teams

• Encourage a fail fast, learn quick mindset• Foster innovation and accountability• Promote open and honest sharing of lessons learned

• Build trust across organizational boundaries-­ Include all the stakeholders

• Expect that it will be a work-­in-­progress

Page 16: DevOps and AWS

1. Customer Obsession2. Ownership3. Invent and Simplify4. Are Right, A Lot5. Hire and Develop the Best6. Insist on the Highest Standards7. Think Big

8. Bias for Action9. Frugality10. Learn and Be Curious11. Earn Trust of Others12. Dive Deep13. Have Backbone;; Disagree and Commit14. Deliver Results

Amazon Leadership Principles

Page 17: DevOps and AWS

DevOps Technology

Page 18: DevOps and AWS

The DevOps Stack

Continuous Deployment

Delivery Pipelines

Deployment Automation

ContinuousIntegration

AutomatedTesting

ConfigurationManagement

Agile

Communication

Page 19: DevOps and AWS

• Infrastructure as code

• Application and Infrastructure version management

• Continuous Integration

• Test Automation

• Continuous Deployment

• Monitoring and logging

DevOps Practices

Page 20: DevOps and AWS

VersionControl CI Server

Package Builder

Deploy ServerCommit to

Git/masterDev

Get / PullCode

AMIs

Distributed BuildsRun Tests in parallel

Staging Env

Test EnvCodeConfigTests

Prod Env

Push

Config InstallCreate

Repo

CloudFormation Templates for Env

Generate

Sample Application Cycle

Page 21: DevOps and AWS

Version Control CI Server

Package Builder

Deploy ServerCommit to

Git/masterDev

Get / PullCode

AMIs

Send Build Report to DevStop everything if build failed

Distributed BuildsRun Tests in parallel

Staging Env

Test EnvCodeConfigTests

Prod Env

Push

Config InstallCreate

Repo

CloudFormation Templates for Env

Generate

Continuous Integration

Page 22: DevOps and AWS

Continuous Integration

• Every developer check-­in initiates a build-­ Builds are fully automated

-­ Tests validate every check-­in

• Instant feedback for developers-­ The build must remain fast

• Minimizes the impact of broken builds-­ Bugs don’t accumulate

• Drives the culture of small, frequent releases

Page 23: DevOps and AWS

Version Control CI Server

Package Builder

Deploy ServerCommit to

Git/masterDev

Get / PullCode

AMIs

Send Build Report to DevStop everything if build failed

Distributed BuildsRun Tests in parallel

Staging Env

Test EnvCodeConfigTests

Prod Env

Push

Config InstallCreate

Repo

CloudFormation Templates for Env

Generate

Continuous Delivery/Deployment

Page 24: DevOps and AWS

Continuous Deployment vs Delivery

Page 25: DevOps and AWS

• Automated, repeatable process to push changes• Hardens, de-­risks the deployment process• Immediate feedback from users• Supports A/B testing or “We test customer reactions to features in production”

• Gives us a breadth of data points across our applications

Continuous Delivery

Page 26: DevOps and AWS

Automated Testing

• Robust, automated testing drives confidence in the entire process

• Testing is not viewed as a “phase” of a project-­ Testing starts on day one

• View failures as successes• Don’t overlook testing the infrastructure-­ Are you ready for the Simian Army?

• Testing is everyone’s responsibility

Page 27: DevOps and AWS

Version Control

Build/CompileCode

Dev

Unit TestApp Code

IT Ops

DR Env

Test Env

Prod Env

Dev Env

ApplicationWriteApp Code

Infrastructure

CloudFormation

tar, war, zipyum, rpmDeploy

AppPackageApplicatio

n

Deploy application only

Deploy infrastructure only

AMI

BuildAMIs

ValidateTemplate

s

WriteInfra Code

DeployInfras

AutomateDeployme

nt

Artifact Repository

Continuous Integration / Deployment & Automation

Page 28: DevOps and AWS

DevOps Stack on AWS

28

MonitorProvisionDeployTestBuildCode

AWS Elastic Beanstalk

CloudWatchCloudFormationCodeDeploy

CodeCommit CodePipeline

AWS Opsworks

AWS Elastic Container Service

Page 29: DevOps and AWS

CodeCommit

• Data redundancy across Availability Zones • Data-­at-­rest encryption• Integrated with AWS Identity and Access Management• No repo size limit

git push CodeCommit

Git objectsin Amazon S3

Git indexin Amazon DynamoDB

Encryption keyin AWS KMS

SSH or HTTPS

Secure, scalable, and managed Git source control

Page 30: DevOps and AWS

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 31: DevOps and AWS

CodePipeline

• Customizable workflow engine• Integrate with partner and custom systems• Visual editor and status

Continuous delivery and release automation, just like Amazon

Build1) Build2) Unit test

1) Deploy2) UI test

Source Beta Production1) Deploy2) Load test

Gamma1) Deploy region12) Deploy region23) Deploy region3

Page 32: DevOps and AWS

CodePipeline : Mockup

Page 33: DevOps and AWS

CodeDeploy

• Scale from 1 instance to thousands• Deploy without downtime• Centralize deployment control and monitoring

Staging

CodeDeployv1, v2, v3

Production

Dev

Coordinate automated deployments, just like Amazon

Applicationrevisions

Deployment groups

Page 34: DevOps and AWS

Step 1: Package your application (with an AppSpecfile)

version: 0.0os: linuxfiles:

- source: chef/destination: /etc/chef/codedeploy

- source: target/hello.wardestination: /var/lib/tomcat6/webapps

hooks:ApplicationStop:- location: deploy_hooks/stop-tomcat.sh

BeforeInstall:- location: deploy_hooks/install-chef.sh

AfterInstall:- location: deploy_hooks/librarian-install.sh

ApplicationStart:- location: deploy_hooks/chef-solo.sh

ValidateService:- location: deploy_hooks/verify_service.sh

Page 35: DevOps and AWS

Step 1: Package your application (with an AppSpecfile)

version: 0.0os: linuxfiles:

- source: chef/destination: /etc/chef/codedeploy

- source: target/hello.wardestination: /var/lib/tomcat6/webapps

hooks:ApplicationStop:- location: deploy_hooks/stop-tomcat.sh

BeforeInstall:- location: deploy_hooks/install-chef.sh

AfterInstall:- location: deploy_hooks/librarian-install.sh

ApplicationStart:- location: deploy_hooks/chef-solo.sh

ValidateService:- location: deploy_hooks/verify_service.sh

Page 36: DevOps and AWS

Step 1: Package your application (with an AppSpecfile)

version: 0.0os: linuxfiles:

- source: chef/destination: /etc/chef/codedeploy

- source: target/hello.wardestination: /var/lib/tomcat6/webapps

hooks:ApplicationStop:- location: deploy_hooks/stop-tomcat.sh

BeforeInstall:- location: deploy_hooks/install-chef.sh

AfterInstall:- location: deploy_hooks/librarian-install.sh

ApplicationStart:- location: deploy_hooks/chef-solo.sh

ValidateService:- location: deploy_hooks/verify_service.sh

Page 37: DevOps and AWS

Step 2: Set up your target environments

Agent Agent Agent

Staging

Agent Agent

Agent Agent

Agent

Agent

Production

Deployment groupDeployment group

Group instances by:• Auto Scaling group• Amazon EC2 tag• On-­premises tag

Page 38: DevOps and AWS

Step 3: Deploy!aws deploy create-deployment \

--application-name MyApp \

--deployment-group-name TargetGroup \

--s3-location bucket=MyBucket,key=MyApp.zip

AWS CLI & SDKsAWS ConsoleCI / CD PartnersGitHub

Page 39: DevOps and AWS

Deployment config – Choose speed

v2 v1 v1 v1 v1 v1 v1 v1

v2 v2 v2 v2 v1 v1 v1 v1

v2 v2 v2 v2 v2 v2 v2 v2

One-­at-­a-­time

Half-­at-­a-­time

All-­at-­once

Page 40: DevOps and AWS

Rolling update – Deploy without downtime

v1v1 v1

Load Balancer

Page 41: DevOps and AWS

Rolling update – Deploy without downtime

v1v2 v1

Load Balancer

Page 42: DevOps and AWS

Rolling update – Deploy without downtime

v2v2 v1

Load Balancer

Page 43: DevOps and AWS

Rolling update – Deploy without downtime

v2v2v2

Load Balancer

Page 44: DevOps and AWS

Rolling update – Deploy without downtime

v2v2 v2

Load Balancer

Page 45: DevOps and AWS

Health Tracking – Catch deployment problems

v2v2 v2

Load Balancer

Page 46: DevOps and AWS

Health tracking – Catch deployment problems

v3 v2 v2Stop

Load Balancer

Page 47: DevOps and AWS

Health tracking – Catch deployment problems

v2v2 v2

Load Balancer

Rollback

Page 48: DevOps and AWS

Health tracking – Catch deployment problems

v2v2 v2

Load Balancer

Page 49: DevOps and AWS

DevOps Stack on AWS

49

MonitorProvisionDeployTestBuildCode

AWS Elastic Beanstalk

CloudWatchCloudFormationCodeDeploy

CodeCommit CodePipeline

AWS Opsworks

AWS Elastic Container Service

Page 50: DevOps and AWS

Automate with AWS CLI

Page 51: DevOps and AWS

Automate with AWS SDK

Page 52: DevOps and AWS

§ Infrastructure as Code

§ Integrates with version control

§ JSON format

§ Templates

§ Stacks

§ Supports most AWS resource typesAWS CloudFormation

AWS Cloudformation

Page 53: DevOps and AWS

"Description" : "Create an EC2 instance running the Amazon Linux 32 bit AMI.”,"Parameters" :

"KeyPair" : "Description" : "The EC2 Key Pair to allow SSH access to the instance", "Type" : "String"

,"Resources" :

"Ec2Instance" : "Type" : "AWS::EC2::Instance", "Properties" :

"KeyName" : "Ref" : "KeyPair" , "ImageId" : "ami-­75g0061f”,“InstanceType” : “m1.medium”

, "Outputs" :

"InstanceId" : "Description" : "The InstanceId of the newly created EC2 instance", "Value" : "Ref" : "Ec2Instance”

AWS Cloudformation

Page 54: DevOps and AWS

Template File Defining Stack

GitSubversionMercurial

Dev

Test

Prod

The entire application can be represented in an AWS CloudFormation template.

Use the version control system of your choice to store and track changes to this template

Build out multiple environments, such as for Development, Test, and Production using the template

AWS Cloudformation

Page 55: DevOps and AWS

Describing Infrastructure with Code

Developers&

OperationsInternal GitCI Server

Pre-­commit Hook

Testing Environment Subnet

CI Workers

Dev Environment VPC Subnet

DEV WEB ELBDev Stack

Tier 1Dev StackTier 2

Dev MySQL DB Instance

DEV APP ELB

VPN TUNNEL

VPN facing VPC Subnet

Internet Gateway

VPN Endpoint

Dev Admin Instance

NAT Instance

Amazon S3

AmazonDynamoDB

Amazon SQS

Amazon CloudFront

Amazon Route 53

This entire infrastructure stack can be constructed, configured, and deployed with code:

Page 56: DevOps and AWS

Infrastructure Code

The code that describes infrastructure should inherit the same values applied to application code

– Not JUST revision control– Make use of bug tracking/ticketing systems– Peer reviews of changes before they happen– Establish infrastructure code patterns/designs– Test infrastructure changes like code changes

Page 57: DevOps and AWS

• AWS OpsWorks makes it easy to deploy & operate apps of all shapes and sizes

• Define configurations for your entire environment in a format that you can maintain and version just like your application source code

• Uses the Chef framework so you can bring your own recipes or leverage 100’s of community-­built configurations

AWS Opsworks

Page 58: DevOps and AWS

• Quickly deploy and manage applications in the AWS cloud without worrying about the application infrastructure

• Automatically handles allthe details of resource provisioning,load balancing & auto-­scaling

• Launch your Java, PHP, .NET, Node.js, Python, Ruby and Docker applications in a matter of minutes

AWS Beanstalk

Page 59: DevOps and AWS

WWW server

WWW server

WWW server

WWW server

Logging Service

PayService

ProcessService

ProcessService

ProcessService

ProcessService

Cluster of underlyingEC2 instances

WWW containers Application-­specific microservices

WWW server

WWW server

Scale out at the

container level

Launching containers is in the order of seconds – very fast to react

AWS Elastic Container Service

Page 60: DevOps and AWS

AWS Tools• CloudFormation• Elastic Beanstalk• OpsWorks

3rd-­Party Tools• Chef• Puppet

What are we deploying? How much control do we want?

Page 61: DevOps and AWS

• Deploy in place – Deploy all at once (Service outage)– Rolling updates

• Blue-­Green Deployment– Discrete environment

• Multiple environments from branches• Support A/B testing• “Rolling DNS”

• Alternate Blue-­Green (Red-­Black?) deployment• Alternate auto scaling group• Avoid messing with DNS

Deployment Approaches

Page 62: DevOps and AWS

CodeDeploy

ALMA Service Icons

Simple Deploy System

Simple Deploy System

Simple Deploy System

Pipelines

Pipelines

Pipelines

Amazon Revision Control

Amazon Revision Control

Amazon Revision Control

Deploy in place – Rolling update

ELB

S3

EC2

Page 63: DevOps and AWS

ALMA Service Icons

Simple Deploy System

Simple Deploy System

Simple Deploy System

Pipelines

Pipelines

Pipelines

Amazon Revision Control

Amazon Revision Control

Amazon Revision Control

Deploy in place – Rolling update

Page 64: DevOps and AWS

ALMA Service Icons

Simple Deploy System

Simple Deploy System

Simple Deploy System

Pipelines

Pipelines

Pipelines

Amazon Revision Control

Amazon Revision Control

Amazon Revision Control

Deploy in place – Rolling update

Page 65: DevOps and AWS

ALMA Service Icons

Simple Deploy System

Simple Deploy System

Simple Deploy System

Pipelines

Pipelines

Pipelines

Amazon Revision Control

Amazon Revision Control

Amazon Revision Control

Deploy in place – Rolling update

Page 66: DevOps and AWS

ALMA Service Icons

Simple Deploy System

Simple Deploy System

Simple Deploy System

Pipelines

Pipelines

Pipelines

Amazon Revision Control

Amazon Revision Control

Amazon Revision Control

Deploy in place – Rolling update

Page 67: DevOps and AWS

ALMA Service Icons

Simple Deploy System

Simple Deploy System

Simple Deploy System

Pipelines

Pipelines

Pipelines

Amazon Revision Control

Amazon Revision Control

Amazon Revision Control

Deploy in place – Rolling update

Page 68: DevOps and AWS

Amazon Route 53

EC2 Instances

ELB

100%

DynamoDB MySQL RDSInstance

ElastiCacheCache Node

Blue-­Green Deployment

Page 69: DevOps and AWS

Amazon Route 53

EC2 Instances

ELB

EC2 Instances

ELB

100%UAT

DynamoDB MySQL RDSInstance

ElastiCacheCache Node

Blue-­Green Deployment

Page 70: DevOps and AWS

Amazon Route 53

EC2 Instances

ELB

EC2 Instances

ELB

90% 10%

DynamoDB MySQL RDSInstance

ElastiCache Cache Node

Blue-­Green Deployment

Page 71: DevOps and AWS

Amazon Route 53

EC2 Instances

ELB

EC2 Instances

ELB

50% 50%

DynamoDB MySQL RDSInstance

ElastiCacheCache Node

Blue-­Green Deployment

Page 72: DevOps and AWS

Amazon Route 53

EC2 Instances

ELB

EC2 Instances

ELB

0% 100%

DynamoDB MySQL RDSInstance

ElastiCacheCache Node

Blue-­Green Deployment

Page 73: DevOps and AWS

Amazon Route 53

EC2 Instances

ELB

EC2 Instances

ELB

0% 100%

DynamoDB MySQL RDSInstance

ElastiCacheCache Node

Blue-­Green Deployment

Page 74: DevOps and AWS

Auto Scaling GroupV1

ELB

Amazon Relational Database

Service (RDS)

Red-­Black Deployment

Page 75: DevOps and AWS

Auto Scaling GroupV1

Auto Scaling GroupV2

ELB

Amazon Relational Database

Service (RDS)

UAT

Red-­Black Deployment

Page 76: DevOps and AWS

Auto Scaling GroupV1

Auto Scaling GroupV2

ELB

Amazon Relational Database

Service (RDS)

ALM | Red-­Black Deployment

Page 77: DevOps and AWS

Auto Scaling GroupV2

ELB

Amazon Relational Database

Service (RDS)

Red-­Black Deployment

Page 78: DevOps and AWS

Monitoring & Metrics : The DevOps Pulse

• Track every resource possible• Alert on services, availability, and response times• Capture, learn, and improve• Share access with everyone on the team• Plan metrics and monitoring into the lifecycle

Page 79: DevOps and AWS
Page 80: DevOps and AWS
Page 81: DevOps and AWS

Where do I go from here?

• Collect Metrics. Graph anything that moves• Log everything, Centralize logging, Log Analytics

• Infrastructure as Code• Automated configuration management• One click environment creation• CI-­CD pipelines• Automated testing

Page 82: DevOps and AWS