Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2015, Amazon Web Services, Inc. or its Affiliat...
What is continuous delivery?
• Software development practice where code changes are
automatically built, tested, and prepa...
Why use containers?
• Process isolation
• Portable
• Fast
• Efficient
Why use containers for continuous delivery?
• Roll out features as quickly as possible
• Predictable and reproducible envi...
Development and deployment workflow
Code
repository
Build
environment
Test
environment
Deployment
environment
Source
Stage 1 - Source
Development environment
Code
repository
Source
Docker and Docker Toolbox
• Docker (Linux > 3.10)
• Docker Toolbox or Docker Beta (OS X, Windows)
• Define app environment...
Dockerfile
FROM ruby:2.2.2
RUN apt-get update -qq && apt-get install -y build-essential
libpq-dev
RUN mkdir -p /opt/web
WO...
Docker Compose
Define and run multi-container applications:
1. Define app environment with Dockerfile
2. Define services t...
docker-compose.yml
proxy:
build: ./proxy
ports:
- "80:80"
links:
- web
web:
build: ./web
command: bundle exec rails server...
Stage 2 - Build
Build environment
Build
environment
Build environment
Containers can be used in two ways:
• Execution environment for the build jobs
• Output of the build pro...
Containers as build execution environment
Containers as build artifacts
Amazon EC2 Container Registry
• Security
• IAM Resource-based Policies
• CloudTrail Audit Logs
• Images encrypted at trans...
Stage 3 - Test
Test environment
Test
environment
Running test inside a container
Usual Docker commands available within your test
environment
Run the container with the co...
Running test against a container
Start a container running in detached mode with an
exposed port serving your app
Run brow...
Stage 4 - Deploy
Deployment environment
Deployment
environment
Amazon EC2 Container Service
• Highly scalable container management service
• Easily manage clusters for any scale
• Flexi...
AWS Elastic Beanstalk
• Deploy and manage applications without worrying about
the infrastructure
• AWS Elastic Beanstalk m...
Amazon ECS CLI
• Easily create Amazon ECS clusters & supporting
resources such as EC2 instances
• Run Docker Compose confi...
Configuring the ECS CLI
# Configure the CLI using environment variables
> export AWS_ACCESS_KEY_ID=<my_access_key>
> expor...
Deploy and scale Compose app with ECS CLI
# Deploy a Compose app as a Task or as a Service
> ecs-cli compose up
> ecs-cli ...
Continuous Delivery
Workflows
Continuous delivery to ECS with Jenkins
4. Push image to
Docker registry
2. Build image from
sources 3. Run test on image
...
Continuous delivery to ECS with Jenkins
Easy Deployment
Developers – Merge into master, done!
Jenkins Build Steps
Trigger ...
Continuous delivery to ECS with CodePipeline
1. Code push
triggers pipeline
2. Lambda function
creates EC2 instance
3. Ima...
Continuous delivery to ECS with CodePipeline
• Lambda custom actions
• Create and terminate EC2 instance
• Update ECS serv...
Amazon ECS continuous delivery partners
Continuous delivery to ECS with Shippable
Demo
Thank You!
Continuous Delivery to Amazon ECS
Upcoming SlideShare
Loading in …5
×

Continuous Delivery to Amazon ECS

2,421 views

Published on

Keeping consistent environments across your development, test, and production systems can be a complex task. Docker containers offer a way to develop and test your application in the same environment in which it runs in production. You can use tools such as Docker Compose for local testing of applications; Jenkins and AWS CodePipeline for code builds and workflow automation; and Amazon EC2 Container Service (ECS) to manage and scale containers.

AWS DevDay San Francisco, June 21, 2016.
Presenter: Nate Slater, Sr. Manager, Solutions Architecture

Published in: Technology
  • Be the first to comment

Continuous Delivery to Amazon ECS

  1. 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Nathaniel Slater, Sr. Manager, Solution Architecture June 21st, 2016 Continuous Delivery to Amazon EC2 Container Service
  2. 2. What is continuous delivery? • Software development practice where code changes are automatically built, tested, and prepared for a release to production. • Extends continuous integration by deploying all code changes to a testing environment and/or a production environment after the build stage. • Developers approve the update to production when they are ready. • Different from continuous deployment, where the push to production happens automatically without explicit approval. • Continuous delivery lets developers automate testing beyond just unit tests to verify application updates across multiple dimensions before deploying.
  3. 3. Why use containers? • Process isolation • Portable • Fast • Efficient
  4. 4. Why use containers for continuous delivery? • Roll out features as quickly as possible • Predictable and reproducible environment • Fast feedback
  5. 5. Development and deployment workflow Code repository Build environment Test environment Deployment environment Source
  6. 6. Stage 1 - Source
  7. 7. Development environment Code repository Source
  8. 8. Docker and Docker Toolbox • Docker (Linux > 3.10) • Docker Toolbox or Docker Beta (OS X, Windows) • Define app environment with Dockerfile
  9. 9. Dockerfile FROM ruby:2.2.2 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev RUN mkdir -p /opt/web WORKDIR /tmp ADD Gemfile /tmp/ ADD Gemfile.lock /tmp/ RUN bundle install ADD . /opt/web WORKDIR /opt/web
  10. 10. Docker Compose Define and run multi-container applications: 1. Define app environment with Dockerfile 2. Define services that make up your app in docker- compose.yml 3. Run docker-compose up to start and run entire app
  11. 11. docker-compose.yml proxy: build: ./proxy ports: - "80:80" links: - web web: build: ./web command: bundle exec rails server -b 0.0.0.0 environment: - SECRET_KEY_BASE=secretkey expose: - "3000"
  12. 12. Stage 2 - Build
  13. 13. Build environment Build environment
  14. 14. Build environment Containers can be used in two ways: • Execution environment for the build jobs • Output of the build process itself
  15. 15. Containers as build execution environment
  16. 16. Containers as build artifacts
  17. 17. Amazon EC2 Container Registry • Security • IAM Resource-based Policies • CloudTrail Audit Logs • Images encrypted at transit and at rest • Easily Manage & Deploy Images • Tight Integration with ECS • Integration with Docker Toolset • Management Console & AWS CLI • Reliability & Performance • S3 Backed
  18. 18. Stage 3 - Test
  19. 19. Test environment Test environment
  20. 20. Running test inside a container Usual Docker commands available within your test environment Run the container with the commands necessary to execute your tests, e.g.: docker run web bundle exec rake test
  21. 21. Running test against a container Start a container running in detached mode with an exposed port serving your app Run browser tests or other black box tests against the container, e.g. headless browser tests
  22. 22. Stage 4 - Deploy
  23. 23. Deployment environment Deployment environment
  24. 24. Amazon EC2 Container Service • Highly scalable container management service • Easily manage clusters for any scale • Flexible container placement • Integrated with other AWS services • Extensible • Amazon ECS concepts • Cluster and container instances • Task definition and task
  25. 25. AWS Elastic Beanstalk • Deploy and manage applications without worrying about the infrastructure • AWS Elastic Beanstalk manages your database, Elastic Load Balancing (ELB), Amazon ECS cluster, monitoring and logging • Docker support • Single container (on Amazon EC2) • Multi container (on Amazon ECS)
  26. 26. Amazon ECS CLI • Easily create Amazon ECS clusters & supporting resources such as EC2 instances • Run Docker Compose configuration files on Amazon ECS • Available today – http://amzn.to/1jBf45a
  27. 27. Configuring the ECS CLI # Configure the CLI using environment variables > export AWS_ACCESS_KEY_ID=<my_access_key> > export AWS_SECRET_ACCESS_KEY=<my_secret_key> > ecs-cli configure --region us-east-1 --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --cluster ecs-cli-demo # Configure the CLI using an existing AWS CLI profile > ecs-cli configure --region us-west-2 --profile ecs-profile -- cluster ecs-cli-demo
  28. 28. Deploy and scale Compose app with ECS CLI # Deploy a Compose app as a Task or as a Service > ecs-cli compose up > ecs-cli compose ps > ecs-cli compose service create > ecs-cli compose service start # Scale a Compose app deployed as a Task or as a Service > ecs-cli compose scale n > ecs-cli compose service scale n
  29. 29. Continuous Delivery Workflows
  30. 30. Continuous delivery to ECS with Jenkins 4. Push image to Docker registry 2. Build image from sources 3. Run test on image 1. Code push triggers build 5. Update Service 6. Pull image
  31. 31. Continuous delivery to ECS with Jenkins Easy Deployment Developers – Merge into master, done! Jenkins Build Steps Trigger via Webhooks, Monitoring, Lambda Build Docker image via Build and Publish plugin Push Docker image into Registry Register Updated Job with ECS API
  32. 32. Continuous delivery to ECS with CodePipeline 1. Code push triggers pipeline 2. Lambda function creates EC2 instance 3. Image is built and pushed to ECR 4. Lambda function terminates EC2 instance 5. Lambda function deploy new task revision to ECS
  33. 33. Continuous delivery to ECS with CodePipeline • Lambda custom actions • Create and terminate EC2 instance • Update ECS service • EC2 instance uses user data to build an image and push it to Amazon ECR
  34. 34. Amazon ECS continuous delivery partners
  35. 35. Continuous delivery to ECS with Shippable
  36. 36. Demo
  37. 37. Thank You!

×