aws december 2015 webinar series - continuous delivery to amazon ec2 container service

32
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Daniele Stroppa, AWS Solutions Architect December 9 th , 2015 Continuous Delivery to Amazon EC2 Container Service

Upload: amazon-web-services

Post on 16-Apr-2017

1.989 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

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

Daniele Stroppa, AWS Solutions Architect

December 9th, 2015

Continuous Delivery to Amazon EC2 Container Service

Page 2: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

What to expect from the session

• Best practices for containers in continuous delivery solutions

• Toolset to implement such solutions

• Demos

Page 3: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Why use containers?

• Process isolation

• Portable

• Fast

• Efficient

Page 4: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Why use containers for continuous delivery?

• Roll out features as quickly as possible

• Predictable and reproducible environment

• Fast feedback

Page 5: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Demo application architecture

Python (Flask)web app

DynamoDB

Page 6: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Development and deployment workflow

Code repository

Build environment

Test environment

Deployment environment

Source

Page 7: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Stage 1 - Source

Page 8: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Development environment

Code repository

Source

Page 9: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Docker and Docker Toolbox

• Docker (Linux > 3.10) or Docker Toolbox (OS X, Windows)

• Define app environment with Dockerfile

Page 10: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Dockerfile

FROM python:2-onbuildCMD [ "python", "./application.py" ]

Page 11: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

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

Page 12: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

docker-compose.yml

signup: build: . ports: - "80:5000" environment: - APP_CONFIG=application.config - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY

Page 13: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Stage 2 - Build

Page 14: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Build environment

Build environment

Page 15: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

ECS CI/CD Partners

Page 16: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Jenkins

Extensible

Flexible builds• Ant or Maven based projects• Docker images

Optionally runs in Docker container

Page 17: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

CloudBees Docker Build and Publish plugin

Page 18: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Amazon EC2 Container Registry

Private Docker Repository• v2 Docker Registry• IAM and AWS Auth integration• Low latency push, pulls, and inspection

Alternatives • Dockerhub• Docker Trusted Registry

New

Page 19: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Stage 3 - Test

Page 20: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Test environment

Test environment

Page 21: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Selenium WebDriver and PhantomJS

import unittestfrom selenium import webdriver

class TestSignup(unittest.TestCase):

def test_signup(self): self.driver.get("http://beta.example.com/#signupModal") self.driver.find_element_by_id("name").send_keys("My Name") self.driver.find_element_by_id("email").send_keys("[email protected]") self.driver.find_element_by_id("signup").click() self.assertTrue(self.find_element_by_id("signupSuccess").isDisplayed()

Page 22: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Jenkins

• Run tests directly via Docker run

• Run tests in a Docker slave on Amazon ECS

Page 23: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

CloudBees Jenkins ECS plugin

Page 24: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Jenkins slave Dockerfile

FROM jenkinsci/jnlp-slaveMAINTAINER Daniele Stroppa ([email protected])# Install Selenium and PhantomJSUSER root# Quiet the update and install outputRUN apt-get update -qq && \ apt-get install -y -qq python-pip nodejs npmRUN ln -s /usr/bin/nodejs /usr/bin/nodeRUN pip install seleniumRUN npm install phantom phantomjs -gUSER jenkinsCOPY test_application.py /home/jenkins/

Page 25: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Stage 4 - Deploy

Page 26: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Deployment environment

Deployment environment

Page 27: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

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

Page 28: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

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

Page 29: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Amazon ECS CLI

> ecs-cli configure --region AWS_REGION --access-key AWS_ACCESS_KEY --secret-key AWS_SECRET_KEY --cluster default > ecs-cli compose service create> ecs-cli compose service up

Page 30: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

It’s Dem-o-clock!

Page 31: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Thank you!

Page 32: AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Container Service

Additional resources

Amazon ECS CLI Github - http://bit.ly/1FJfWyQ

CloudBees Docker Build and Publish plugin - http://bit.ly/1LUryzZ

CloudBees Jenkins ECS plugin - http://bit.ly/1RiMpNK