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

Post on 16-Apr-2017

1.991 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

© 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

What to expect from the session

• Best practices for containers in continuous delivery solutions

• Toolset to implement such solutions

• Demos

Why use containers?

• Process isolation

• Portable

• Fast

• Efficient

Why use containers for continuous delivery?

• Roll out features as quickly as possible

• Predictable and reproducible environment

• Fast feedback

Demo application architecture

Python (Flask)web app

DynamoDB

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) or Docker Toolbox (OS X, Windows)

• Define app environment with Dockerfile

Dockerfile

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

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

docker-compose.yml

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

Stage 2 - Build

Build environment

Build environment

ECS CI/CD Partners

Jenkins

Extensible

Flexible builds• Ant or Maven based projects• Docker images

Optionally runs in Docker container

CloudBees Docker Build and Publish plugin

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

Stage 3 - Test

Test environment

Test environment

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("myemail@name.com") self.driver.find_element_by_id("signup").click() self.assertTrue(self.find_element_by_id("signupSuccess").isDisplayed()

Jenkins

• Run tests directly via Docker run

• Run tests in a Docker slave on Amazon ECS

CloudBees Jenkins ECS plugin

Jenkins slave Dockerfile

FROM jenkinsci/jnlp-slaveMAINTAINER Daniele Stroppa (stroppad@amazon.com)# 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/

Stage 4 - Deploy

Deployment environment

Deployment environment

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

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

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

It’s Dem-o-clock!

Thank you!

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

top related