making sense out of amazon ecs

43
MAKING SENSE OUT OF AMAZON ECS Swapnil Dahiphale DevOps Engineer 13 Feb 2016, DevOps Meetup Banglore

Upload: whitehedge-technologies-inc

Post on 15-Apr-2017

498 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Making Sense out of Amazon ECS

MAKING SENSE OUT OF AMAZON ECS

Swapnil DahiphaleDevOps Engineer

13 Feb 2016, DevOps Meetup Banglore

Page 2: Making Sense out of Amazon ECS

WhiteHedge

2

INTRODUCTION - HELLO

WhiteHedgeHello! Welcome to WhiteHedge

Our Work , Our ClientsWhiteHedge is an Agile Software Product Development company. But what reallydescribes us is what we think about Our Work , Our Clients.

We have deep experience in some of the most sought-after technology domains in theindustry today: Mobile Development, Big Data Analytics, Cloud Computing, andDevOps. Having deep knowledge in these domains make us stand out as the best andthe coolest provider of services. Our DevOps will bring you a single team that workstogether with continuous development, continuous testing, continuous deployments,logging, monitoring and security.

Page 3: Making Sense out of Amazon ECS

WhiteHedge

3

WHITEHEDGE - AN OVERVIEW

Global Presence

+

+

+

+

+

+

Agile + Flexible

Thorough + Quick Learner

Competitive + Comprehensive

Honest + Transparent

Young + Mature

Innovative + Creative

More about us …What defines us ?

California

New Jersey Rotterdam

Pune

Envision Products | Convert into businesses

100+ employees | 50+ live products world-wide

The best of the Talent and Infrastructure

Started 2003 | Focused Agile Product Development

Self funded | Well funded | Profitable

Page 4: Making Sense out of Amazon ECS

WhiteHedge

4

TABLE OF CONTENTS - OUR AGENDA

Containers

1

Use case

2

Orchestration

3

Introduction to ECS

4

Key Components

6

Architecture

7

Overview of Build Process

8

Why ECS?

5

Page 5: Making Sense out of Amazon ECS

CONTAINERS

Page 6: Making Sense out of Amazon ECS

WhiteHedgeWHAT ARE CONTAINERS?

OS virtualization

Process isolation

Images

Automation

Bins/Libs

Docker Engine

Bins/Libs

App2App1

Host OS

Server

Guest OS

Hypervisor

Guest OS

Bins/LibsBin/Libs

Host OS

Server

App1 App2 Container 1 Container 2

VM 1 VM 2

Page 7: Making Sense out of Amazon ECS

WhiteHedge

“automates the deployment of anyapplication as a lightweight,portable, self-sufficient containerthat will run virtually anywhere”

CONTAINERS

Page 8: Making Sense out of Amazon ECS

USE CASE

Page 9: Making Sense out of Amazon ECS

WhiteHedgeUSE CASE

A highly available RESTful API server which fetchesdata from third-party services and serves its clients.

Page 10: Making Sense out of Amazon ECS

WhiteHedgeARCHITECTURE

Page 11: Making Sense out of Amazon ECS

WhiteHedgeCONTINUOUS DELIVERY WITH JENKINS

Build Image

Push Image

CodeDeploy

Page 12: Making Sense out of Amazon ECS

WhiteHedgeTHE PROBLEM

• A large monolithic application that was difficult to run, deploy, and scale.

• We were deploying a single docker container to run multiple processes.

• Docker was monitored and we were redeploying docker instance if the docker instance runs into problems.

• We used to evaluate capacity of EC2 instance manually and are running one container per instance

Page 13: Making Sense out of Amazon ECS

WhiteHedgeTHE CHALLENGE

• Use microservices architecture using docker

• Orchestration of dockers

• Replicate infrastructure to many regions

Page 14: Making Sense out of Amazon ECS

ORCHESTRATION

Page 15: Making Sense out of Amazon ECS

WhiteHedgeORCHESTRATION

Bins/Libs

Docker Engine

App1

Host OS

Server

Bins/Libs

App2

Page 16: Making Sense out of Amazon ECS

WhiteHedgeORCHESTRATION

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Docker Engine

Host OS

Server

Page 17: Making Sense out of Amazon ECS

Why EC2 Container Service?

Page 18: Making Sense out of Amazon ECS

WhiteHedgeWHY ECS?

• It is a managed service!

•Easy to integrate with other AWS services

• It is great for storing and enforcing task state

•Designed with custom schedulers in mind

•The agent code is available on a public GitHub repo and … it is in GO!

Page 19: Making Sense out of Amazon ECS

WhiteHedgeWHAT ELSE DID WE LOOK AT?

Home-grown Tech

Tried, but proved to be unreliable

Difficult to handle coordination and synchronization

Powerful but hard to productionize

Needs developers with Experience

Not a managed service, higher Opsload

“Amazon ECS enabled us to focus on releasing new software rather than spending time managing clusters”

Page 20: Making Sense out of Amazon ECS

Introduction to ECS

Page 21: Making Sense out of Amazon ECS

WhiteHedge

“a highly scalable, high performance containermanagement service that supports dockercontainers and allows you to easily run and manageDocker-enabled applications across cluster of EC2instances”

WHAT IS ECS?

Page 22: Making Sense out of Amazon ECS

WhiteHedgeWHAT IS ECS?

• Building Block Service

• Easily Manage Clusters for Any ScaleNothing to runComplete stateControl and monitoringScale

• Flexible Container Placement• Designed for use with other AWS services• Secure• Extensible - Comprehensive APIs

Page 23: Making Sense out of Amazon ECS

WhiteHedgeKEY COMPONENTS

Container Instances

Clusters

Tasks

Run a task

Create a service

Page 24: Making Sense out of Amazon ECS

WhiteHedgeKEY COMPONENTS

• Amazon EC2 Instances

• Docker daemon

• Amazon ECS agent

Container InstancesClusters

Tasks

Run a task

Create a service

Page 25: Making Sense out of Amazon ECS

WhiteHedgeKEY COMPONENTS

• Grouping of Container

Instances

• Resource pool

• Regional

• Start empty, dynamically

scalable

Container Instances

ClustersTasks

Run a task

Create a service

Page 26: Making Sense out of Amazon ECS

WhiteHedgeKEY COMPONENTS

• Unit of work

• Grouping of related

Containers

• Run on Container Instances

Container Instances

Clusters

TasksRun a task

Create a service

Page 27: Making Sense out of Amazon ECS

WhiteHedgeKEY 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 28: Making Sense out of Amazon ECS

WhiteHedge

{"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  ourtask

10  CPU  units  (1024  is  full  CPU),    500  megabytes  ofmemory

Expose  port  80  in containerto  port  80  on host

Create  and  mount volumes

Page 29: Making Sense out of Amazon ECS

WhiteHedge

{"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

}

KEY COMPONENTS: TASK DEFINITIONS

[{

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

"db"],"entryPoint": [

"/bin/sh","-c"

],"environment": [

…],"portMappings": [

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

}]

},]

From  Docker Hub

Mount  volume  from  othercontainer

Command  toexec

Page 30: Making Sense out of Amazon ECS

WhiteHedgeKEY COMPONENTS

Good for short-lived containers,

e.g. batch jobs

Container Instances

Clusters

Tasks

Run a taskCreate a service

Page 31: Making Sense out of Amazon ECS

WhiteHedgeKEY COMPONENTS

Good for long-running

applications and services

Container Instances

Clusters

Tasks

Run a task

Create a service

Page 32: Making Sense out of Amazon ECS

Typical user workflow

Page 33: Making Sense out of Amazon ECS

WhiteHedgeTYPICAL USER WORKFLOW

I  want  to  run  aservice

Page 34: Making Sense out of Amazon ECS

WhiteHedgeTYPICAL USER WORKFLOW

Run Instances AmazonEC2

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

Page 35: Making Sense out of Amazon ECS

WhiteHedgeTYPICAL USER WORKFLOW

Create  Task Definition

Declare resourcerequirements forcontainers

Shared  DataVolume

Node.jsApp Time  of day    App

Page 36: Making Sense out of Amazon ECS

WhiteHedgeTYPICAL USER WORKFLOW

Create Service

Declare resourcerequirements forservice

Shared  DataVolume

Node.jsApp Time  of day    App

Elastic    Load    

Balancing

X 3

Page 37: Making Sense out of Amazon ECS

WhiteHedgeTYPICAL USER WORKFLOW

Describe Service

Page 38: Making Sense out of Amazon ECS

Architecture with ECS

Page 39: Making Sense out of Amazon ECS

WhiteHedgeARCHITECTURE

Page 40: Making Sense out of Amazon ECS

WhiteHedgeCONTINUOUS DELIVERY WITH JENKINS

Build Image

Push Image

Update ECS service

Page 41: Making Sense out of Amazon ECS

WhiteHedge

Features Without ECS Using ECS

High availability If any of the container dies, we

have to redeploy on all servers.

Restarts that container itself.

(Its a cluster management

system so it will always be in

desired state)

Managing number of

containers on a given EC2

instance

It will be complicated to run

and manage multiple

containers effectively.

Can manage multiple

containers.

Deployment method Handle deployments using

various methods.

(CodeDeploy, chef etc.)

ECS manages deployment of

new revision.

COMPARISON OF ARCHITECTURES

Page 42: Making Sense out of Amazon ECS

WhiteHedge

42

FOLLOW US

Questions?

http://www.whitehedge.com/devops.htmlSwapnil Dahiphale

[email protected]

- SOCIAL NETWORKS / PHONE

Page 43: Making Sense out of Amazon ECS

THANK YOU!Have a Nice Day!

Swapnil Dahiphale

@Swapnil2233

[email protected]