pursuit of stability growing aws ecs in production · pursuit of stability growing aws ecs in...

55
Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018

Upload: others

Post on 25-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Pursuit of stability

Growing AWS ECS in production

Alexander Köhler Frankfurt, September 2018

Page 2: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

2

Alexander Köhler

DevOps EngineerSystems Engineer

Big Data Engineer

Application Developer

@la3mmchen

Page 3: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

inovex is an IT project house

with a focus on digital transformation

‣ Product Discovery · Product Ownership

‣ Web · UI/UX · Replatforming · Microservices

‣ Mobile · Apps · Smart Devices · Robotics

‣ Big Data & Business Intelligence Platforms

‣ Data Science · Data Products · Search · Deep Learning

‣ Data Center Automation · DevOps · Cloud · Hosting

‣ Agile Training · Technology Training · Coaching

Using technology to inspire our clients. And ourselves.

Karlsruhe · Pforzheim · Stuttgart · München · Köln · Hamburg

www.inovex.de/en

Page 4: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat the customer told us to do.

4

host web applications that our SCRUM team develops

Page 5: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat the customer didn’t told us right on the spot.

5

host web applications that our SCRUM team develops

different languages (e.g.

java, go)

SSO solution Multi-

stage setup

Cloud based

Need for an android build

server

Distribute APKs

Different maintainers

Page 6: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

6

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

Page 7: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

7

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

different languages (e.g.

java, go)

SSO solution Multi-

stage setup

Cloud based

Android Build Server

Distribute APKs

Different maintainers

Page 8: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

8

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

SSO solution Multi-

stage setup

Cloud based

Android Build Server

Distribute APKs

Different maintainers

Wrap the apps in containers

Page 9: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

9

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

SSO solution Multi-

stage setup

Cloud based

Android Build Server

Distribute APKs

Wrap the apps in containers Add CI/CD

pipelines

Page 10: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

10

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

SSO solution Multi-

stage setup

Android Build Server

Distribute APKs

Wrap the apps in containers Add CI/CD

pipelinesAWS

Page 11: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

11

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

Multi-stage setup

Android Build Server

Distribute APKs

Wrap the apps in containers Add CI/CD

pipelinesAWS

Keycloak

Page 12: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

12

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

Android Build Server

Distribute APKs

Wrap the apps in containers Add CI/CD

pipelinesAWS

Keycloak

Infrastructure-as-Code to deploy in

multiple AWS accounts

Page 13: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

13

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

Distribute APKs

Wrap the apps in containers Add CI/CD

pipelinesAWS

Keycloak

Infrastructure-as-Code to deploy in

multiple AWS accounts

Ec2 instance with planned builds

Page 14: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

The startWhat we told the customer we could do.

14

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

Wrap the apps in containers Add CI/CD

pipelinesAWS

Keycloak

Infrastructure-as-Code to deploy in

multiple AWS accounts

Ec2 instance with planned builds Provide S3 buckets for

upload/download

Page 15: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1

15

Page 16: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1“Containers in production.”

16

Back in 2017: No EKS.But Kops with AWS support.

Page 17: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1“Containers in production.”

17

Back in 2017: No AWS Fargate. (as long as i remember)But still Kops with AWS support.

Page 18: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1“Let‘s bring containers in production“, they said.

18

AWS ECS to the rescue.Easy setup, I’ve heard.

Page 19: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1“Let‘s bring containers in production“, they said.

19

Page 20: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1“Let‘s bring containers in production“, they said.

20

ECS itself is pretty easy, but there are some more components involved.

Page 21: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1How exactly bring container now into production?

21

ECS Cluster

ECS Service ECS Service ...

Page 22: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1How exactly bring container now into production?

22

ECS Cluster

ECS Service ECS Service ...

task. (id 42) task. (id 41) …

Page 23: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1How exactly bring container now into production?

23

ECS Cluster

EC2 node

ECS Service ECS Service ...

EC2 node ...VPC

ECS Ami

Page 24: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1How exactly bring container now into production?

24

ECS Cluster

EC2 node

ECS Service ECS Service ...

EC2 node ...

Docker Registry

VPC

ECS Ami

Page 25: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 1How exactly bring container now into production?

25

ECS Cluster

EC2 node

Load balancer

ECS Service ECS Service ...

EC2 node ...

DNS Certs

Docker Registry

VPC

ECS Ami

Page 26: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 2

26

Page 27: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 2So, replace ECS Ami

27

What we knew good: Ubuntu 16.04 LTS. Should be easy.

Page 28: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 2Move away from ECS AMI

28

ECS Cluster

EC2 node

Load balancer

ECS Service ECS Service ...

EC2 node ...

DNS Certs

Docker Registry

VPC

ECS Ami Ubuntu AMI

Page 29: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

ECS AMI

Round 2Move away from ECS AMI

29

Docker

ECS agent

Ubuntu

Page 30: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

ECS AMI

Round 2Move away from ECS AMI

30

Docker

ECS agent

Ubuntu

Docker

ECS agent

Page 31: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

ECS AMI

Round 2Move away from ECS AMI

31

Docker

ECS agent

Ubuntu

EBS Volume

Docker

Docker-Root at EBS

ECS agent

Page 32: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

32

Round 3

Page 33: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 3Bring up a monitoring solution

33

It’s AWS. There is cloudwatch?Or do prometheus like everyone else?

Page 34: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 3Bring up a monitoring solution

34

We did prometheus. And ended up with something like this.

Page 35: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 3Let prometheus collect all the metrics from all the sources.

35

Monitoring stack

ECS cluster

Container

EC2 instancesA

WS A

pi

Page 36: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 3Let prometheus collect all the metrics from all the sources.

36

Monitoring stack

ECS cluster

Container

EC2 instancesA

WS A

pi

Prometheus

ECS Discovery

EC2 discovery

AlertmanagerGrafana

BlackboxExporter

Page 37: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 3Let prometheus collect all the metrics from all the sources.

37

Monitoring stack

ECS cluster

Container

EC2 instancesA

WS A

pi

Prometheus

ECS Discovery

EC2 discovery

AlertmanagerGrafana

BlackboxExporter

Node Exporter

Docker Daemon Metrics

ContainerStarts

CAdvisor

Page 38: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 4

38

Ever tried to debug Keycloak in a container not starting properly on a distributed infrastructure?

We did. We ended up somehow like this.

Read all the shells.

Page 39: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 4

39

Lets collect the logs.

Read all the shells. Nay.

Page 40: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 4Setup a log pipeline.

40

ECS cluster

Container

EC2 instances

Docker

Elasticsearch Service on AWS

Page 41: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 4Setup a log pipeline.

41

ECS cluster

Container

EC2 instances

Docker json files

filebeat

processor “add_docker_metadata” Elasticsearch

Service on AWS

Page 42: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

42

Round 5Add this magic thing called CI/CD.

Page 43: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

gitlab-runner

make

gitlab-runner

docker build

gitlab-runner

docker push

gitlab-runner

terraform apply

gitlab repository gitlab repositorydeploy/

gitlab registry(docker registry)

gitlab registry(docker registry)

AWS ECR(docker registry)

build artifact(e.g. dist/)

build artifact(e.g. dist/)

ECS cluster(running service)

Executed in both the Dev and the Test environment.

Round 5The pipeline

43

Actually, pretty easy.Some different kind of “easy”.

Page 44: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 5Toolstack

44

Gitlab

ECS Service

ECS Cluster

EC2

Page 45: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 5Toolstack

45

Gitlab

ECS Service

ECS ClusterGitlab Runner

EC2

Terraform

Page 46: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Round 5Toolstack

46

Gitlab

ECS Service

ECS ClusterGitlab Runner

EC2

Terraform

Terraform (aws-

infrastructure)

ECS Service

ECS ClusterGitlabRunner

EC2

Page 47: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Gitlab-CI

Round 5The pipeline itself

47

Push to ECR-Dev

Build App Wrap in Docker

docker login ecr registrydocker push

Add to GitlabDocker

Registry

Push to next-Stage

Deploy ECS services

1.Pull from gitlab2.Push to ECR

Page 48: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

48

Final round.

Page 49: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

ConclusionWhat I’ve talked about

49

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

Wrap the apps in containers Add CI/CD

pipelinesAWS

Keycloak

Infrastructure-as-Code to deploy in

multiple AWS accounts

Ec2 instance with planned builds Provide S3 buckets for

upload/download

Page 50: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

ConclusionWhat we build but wasn’t mentioned.

50

Build a modern (cloud native) infrastructure, wrap everything in ci/cd, build management components like monitoring, add some magic sugar

on top and host your web applications in AWS.

Wrap the apps in containers Add CI/CD

pipelinesAWS

Keycloak

Infrastructure-as-Code to deploy in

multiple AWS accounts

Ec2 instance with planned builds Provide S3 buckets for

upload/download

Page 51: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Final wordsBring container in production.

51

ECS itself: easy and straightforward.The complete stack with supporting tools: can be tricky.

Page 52: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Final wordsProven tool chain

52

Provision with terraform.Gitlab-CI as CI/CD base.

Gitlab-Runner as workhorse.

Page 53: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Final wordsWhat we might do in another way the second time.

53

Take a clearer decision about the usage of additional AWS service.

Page 54: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Final wordsWhat we might do in another way the second time.

54

Re-check if fargate isn’t the better solution for most of the services

Page 55: Pursuit of stability Growing AWS ECS in production · Pursuit of stability Growing AWS ECS in production Alexander Köhler Frankfurt, September 2018. 2 Alexander Köhler ... Let prometheus

Vielen DankAlexander Köhler

DevOps Engineer

inovex GmbH

Ludwig-Erhard-Allee 6

76131 Karlsruhe

[email protected]

https://github.com/inovex/aws-ecs-kickstart