introduction to amazon ec2 container service and setting up build pipeline with ecs and jenkins

42
Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins Swapnil Dahiphale DevOps Engineer, WhiteHedge Technologies

Upload: swapnil-dahiphale

Post on 13-Apr-2017

588 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Introduction to Amazon EC2 Container Service and setting up build pipeline with

ECS and Jenkins

Swapnil DahiphaleDevOps Engineer, WhiteHedge Technologies

Page 2: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Agenda

• Containers• Orchestration • Why ECS?• What is ECS?• Key Components• Typical user workflow• Build pipeline with Jenkins and ECS

Page 3: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Containers

“autom ates the deployment of any appl ication as a l ightweight, portable, self-sufficient container that will run virtual ly anywhere”

Page 4: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What are containers?

OS virtualization

Process isolation

Automation

ImagesServer

Guest OS

Bins/Libs Bins/Libs

App2App1

Page 5: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Why use Docker?

With Docker we can solve many problems

• “it works on my machine”• reducing build & deploy time• Infrastructure configuration – automation!• Libs dependency hell• Cost control and granularity

Page 6: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

A container pipelineIT Operations

BaseImage

PatchesUtilities

Page 7: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

A container pipelineIT Operations

BaseImage

PatchesUtilities

Ruby

Redis

Logger

Page 8: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

A container pipelineIT Operations Developer

BaseImage

PatchesUtilities

Ruby

Redis

Logger

App

Page 9: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

A container pipeline

BaseImage

PatchesUtilities

IT Operations Developer

Ruby

Redis

Logger

App

Page 10: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Guest OS

Server

Bins/Libs Bins/Libs

App2App1

$ docker run myimage

Page 11: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins
Page 12: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Orchestration!

Page 13: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Orchestration is a mean to Automate Manual Process

Orchestration

Page 14: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Why Orchestration?

• Microservice Architectures• Fault tolerance / High Availability• Scalability• Resource Utilization

Page 15: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Orchestration Tools

• Kubernetes• Docker Swarm• Amazon EC2 Container Service

Page 16: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Why EC2 Container Service ?

Page 17: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins
Page 18: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins
Page 19: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What is ECS?

Building Block Service

Page 20: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What is ECS?

Easily Manage Clusters for Any Scale

• Nothing to run• Complete state• Control and monitoring• Scale

ECS List* and Describe* API actions

Page 21: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What is ECS?

Flexible Container Placement

• Applications• Batch jobs• Multiple schedulers

Page 22: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What is ECS?

Designed for use with other AWS services

• Virtual Private Cloud• Elastic Load Balancing• Elastic Block Store• IAM• CloudTrail

Page 23: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What is ECS?

Performance at scale

Page 24: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What is ECS?

Secure

Your containers,

Your instances

Page 25: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

What is ECS?

Extensible

• Comprehensive APIs• Open source agent• Custom schedulers

Page 26: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Key Components

Tasks

Containers

Clusters

Container Instances

Page 27: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Key Components: Container Instances

Amazon EC2 instances

Docker daemon

Amazon ECS agent

Page 28: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Key Components: Clusters

Regional

Resource pool

Grouping of Container Instances

Start empty, dynamically scalable

Page 29: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Key Components: Tasks

Unit of work

Grouping of related containers

Run on Container Instances

Page 30: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Key components: task definitions{

"environment": [],"name": "simple-demo","image": "my-demo", "cpu": 10,"memory": 500, "portMappings": [

{"containerPort": 80,"hostPort": 80

}],"mountPoints": [

{"sourceVolume": "my-vol", "containerPath": "/var/www/my-

vol"}

],"entryPoint": [

"/usr/sbin/apache2", "-D",

"FOREGROUND"],"essential": true

},

{"name": "busybox","image": "busybox", "cpu": 10,"memory": 500, "volumesFrom": [{

"sourceContainer": "simple-demo"

}],"entryPoint"

: [ "sh",

"-c"],"command": [

"/bin/sh -c \"while true; do

/bin/date > /var/www/my-vol/date; sleep 1; done\""

],"essential":

false}

Page 31: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

{"environment": [],"name": "simple-demo","image": "amazon/amazon-ecs-sample", "cpu": 10,"memory": 500, "portMappings": [

{"containerPort": 80,"hostPort": 80

}],"mountPoints": [

{"sourceVolume": "my-vol", "containerPath": "/var/www/my-

vol"}

],"entryPoint": [

"/usr/sbin/apache2", "-D",

"FOREGROUND"],"essential": true

},

Key components: task definitions

Essential to our task

10 CPU units (1024 is full CPU), 500 megabytes of memory

Expose port 80 in containerto port 80 on host

Create and mount volumes

Page 32: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

{

Key components: task definitions"name": "busybox","image": "busybox", "cpu": 10,"memory": 500, "volumesFrom": [{"sourceContainer":

"simple-demo"}],

"entryPoint": [ "sh","-c"

],"command": [

"/bin/sh -c \"while true; do

/bin/date > /var/www/my-vol/date; sleep 1; done\""

],"essential": false

}

[{

"image": "tutum/wordpress-stackable", "name": "wordpress","cpu": 10,"memory": 500,"essential": true, "links": [

"db"],"entryPoint": [

"/bin/sh","-c"

],"environment": [

…],"portMappings": [

{"containerPor

t": 80,"hostPort":

80}

]},]

From Docker Hub

Mount volume from other container

Command to exec

Page 33: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Typical user workflowI want to run a service

Page 34: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Typical user workflow

Run Instances AmazonEC2

Use custom AMI with Docker support and ECS Agent. Instances will register with default cluster.

Page 35: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Typical user workflow

Create Task Definition

Declare resource requirements for containers

Shared Data Volume

Node.js App Time of day App

Page 36: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Typical user workflow

Create Service

Declare resource requirements for service

Shared Data Volume

Node.js App Time of day App

Elastic Load

Balancing

X 3

Page 37: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Typical user workflow

Describe Service

Page 38: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Demo

Page 39: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Build Pipeline with ECS and Jenkins

Page 40: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Continuous delivery with Jenkins

Build image

Push image

Update service

Page 41: Introduction to Amazon EC2 Container Service and setting up build pipeline with ECS and Jenkins

Q&A