making sense out of amazon ec2 container service

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

Upload: swapnil-dahiphale

Post on 22-Jan-2018

423 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Making Sense Out of Amazon EC2 Container Service

MAKING SENSE OUT OF AMAZON ECS

Swapnil DahiphaleDevOps Engineer

13 Feb 2016, DevOps Meetup Banglore

Page 2: Making Sense Out of Amazon EC2 Container Service

WhiteHedge

2

INTRODUCTION - HELLO

Hello! Welcome to WhiteHedge

WhiteHedge 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 EC2 Container Service

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

InfrastructureStarted 2003 | Focused Agile

Product Development

Self funded | Well funded |

Profitable

Page 4: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

CONTAINERS

Page 6: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

WhiteHedge

“auto mat es the deployment of anyapplicat ion as a lightweight, portable,self-sufficient container that will runvirtually anywhere”

CONTAINERS

Page 8: Making Sense Out of Amazon EC2 Container Service

USE CASE

Page 9: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

WhiteHedgeARCHITECTURE

Page 11: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeCONTINUOUS DELIVERY WITH JENKINS

Build Image

Push Image

CodeDeploy

Page 12: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

WhiteHedgeTHE CHALLENGE

• Use microservices architecture using docker

• Orchestration of dockers

• Replicate infrastructure to many regions

Page 14: Making Sense Out of Amazon EC2 Container Service

ORCHESTRATION

Page 15: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeORCHESTRATION

Bins/Libs

Docker Engine

App1

Host OS

Server

Bins/Libs

App2

Page 16: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

Why EC2 Container Service?

Page 18: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

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 EC2 Container Service

Introduction to ECS

Page 21: Making Sense Out of Amazon EC2 Container Service

WhiteHedge

“a highly scalable, high performance containermanagement service that supports docker containersand allows you to easily run and manage Docker-enabled applications across cluster of EC2 instances”

WHAT IS ECS?

Page 22: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

WhiteHedgeKEY COMPONENTS

Container Instances

Clusters

Tasks

Run a task

Create a service

Page 24: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeKEY COMPONENTS

• Amazon EC2 Instances

• Docker daemon

• Amazon ECS agent

Container Instances

Clusters

Tasks

Run a task

Create a service

Page 25: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeKEY COMPONENTS

• Grouping of Container

Instances

• Resource pool

• Regional

• Start empty, dynamically

scalable

Container Instances

Clusters

Tasks

Run a task

Create a service

Page 26: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeKEY COMPONENTS

• Unit of work

• Grouping of related

Containers

• Run on Container Instances

Container Instances

Clusters

Tasks

Run a task

Create a service

Page 27: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

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 EC2 Container Service

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 EC2 Container Service

WhiteHedgeKEY COMPONENTS

Good for short-lived containers,

e.g. batch jobs

Container Instances

Clusters

Tasks

Run a task

Create a service

Page 31: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

Typical user workflow

Page 33: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeTYPICAL USER WORKFLOW

I want to run aservice

Page 34: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

WhiteHedgeTYPICAL USER WORKFLOW

Create Task Definition

Declare resourcerequirements forcontainers

Shared DataVolume

Node.jsApp Time of day App

Page 36: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

WhiteHedgeTYPICAL USER WORKFLOW

Describe Service

Page 38: Making Sense Out of Amazon EC2 Container Service

Architecture with ECS

Page 39: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeARCHITECTURE

Page 40: Making Sense Out of Amazon EC2 Container Service

WhiteHedgeCONTINUOUS DELIVERY WITH JENKINS

Build Image

Push Image

Update ECS service

Page 41: Making Sense Out of Amazon EC2 Container Service

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 EC2 Container Service

WhiteHedge

42

FOLLOW US

Questions?

http://www.whitehedge.com/devops.html

Swapnil [email protected]

- SOCIAL NETWORKS / PHONE

Page 43: Making Sense Out of Amazon EC2 Container Service

THANK YOU!Have a Nice Day!

Swapnil Dahiphale

@Swapnil2233

[email protected]