carpooling 100% containers powered · a change in my own app/container: “immutable” ... rkt...

45
100% Containers Powered Carpooling

Upload: others

Post on 04-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

100% Containers Powered Carpooling

Page 2: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Maxime FouilleulDatabase Reliability Engineer

Page 3: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Today’s agenda

BlaBlaCar - Facts & Figures

Infrastructure Ecosystem - 100% containers powered carpooling

Stateful Services into containers - MariaDB as an example

Next challenges - Kubernetes, the Cloud

Page 4: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

BlaBlaCarFacts & Figures

Page 5: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

60 million members

Foundedin 2006

1 million tonnesless CO

2

In the past year

30 million mobileapp downloadsiPhone and Android

15 milliontravellers /quarter

Currently in22 countriesFrance, Spain, UK, Italy, Poland, Hungary, Croatia, Serbia, Romania, Germany, Belgium, India, Mexico, The Netherlands, Luxembourg, Portugal, Ukraine, Czech Republic, Slovakia, Russia, Brazil and Turkey.

Facts and Figures

Page 6: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

MariaDB Redis PostgreSQL

Transactional

Our prod data ecosystem

Cassandra

DistributedVolatile

Spatial

Kafka

Stream

ElasticSearch

Search

Page 7: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Infrastructure Ecosystem 100% containers powered carpooling

Page 8: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Why containers?

Page 9: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Homogeneous HardwareFrom this

srv_001

svc_001

srv_002

svc_002

srv_003

svc_003

srv_004

svc_004

srv_005

svc_005

srv_006

svc_006

srv_007

svc_007

srv_008

svc_008

srv_009

svc_009

srv_010

svc_010

srv_011

svc_011

srv_012

svc_012

srv_013

srv_014

svc_013

svc_014

Page 10: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Homogeneous HardwareTo that

srv_007

srv_008

svc_013

srv_005

srv_006

srv_003

srv_004

srv_001

srv_002

svc_001

svc_002

svc_003svc_004svc_005

svc_006

svc_007

svc_010

svc_008

svc_011

svc_009

svc_012

svc_014

Page 11: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Homogeneous Hardware - “Pets vs Cattle”

Easier to replace broken hardware

Cost Effective

Easier to manage

Page 12: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

redis trip-meeting-point

Homogeneous Deploymenttrip-meeting-point application

cat ./prod-dc1/services/trip-meeting-point/service-manifest.yml---containers: - aci.blbl.cr/aci-trip-meeting-point:20180928.145115-v-979da34 - aci.blbl.cr/aci-go-synapse:15-40 - aci.blbl.cr/aci-go-nerve:21-27 - aci.blbl.cr/aci-logshipper:27

nodes: - hostname: trip-meeting-point1 gelf: level: INFO fleet: - MachineMetadata=rack=110 - Conflicts=*trip-meeting-point* - hostname: trip-meeting-point2 fleet: - MachineMetadata=rack=210 - Conflicts=*trip-meeting-point* - hostname: trip-meeting-point3 fleet: - MachineMetadata=rack=310 - Conflicts=*trip-meeting-point*

cat ./prod-dc1/services/redis-meeting-point/service-manifest.yml---containers: - aci.blbl.cr/aci-redis:4.0.2-1 - aci.blbl.cr/aci-redis-dictator:20 - aci.blbl.cr/aci-go-nerve:21-27 - aci.blbl.cr/aci-prometheus-redis-exporter:0.12.2-1

nodes: - hostname: redis-meeting-point1 fleet: - MachineMetadata=rack=110 - Conflicts=*redis-meeting-point* - hostname: redis-meeting-point2 fleet: - MachineMetadata=rack=210 - Conflicts=*redis-meeting-point* - hostname: redis-meeting-point3 fleet: - MachineMetadata=rack=310 - Conflicts=*redis-meeting-point*

ggn prod-dc1 trip-meeting-point update -y ggn prod-dc1 redis-meeting-point update -y

Page 13: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Volatile by designtrip-meeting-point dependencies

cat ./prod-dc1/services/trip-meeting-point/service-manifest.yml---containers: - aci.blbl.cr/aci-trip-meeting-point:20180928.145115-v-979da34 - aci.blbl.cr/aci-go-synapse:15-41 - aci.blbl.cr/aci-go-nerve:21-27 - aci.blbl.cr/aci-logshipper:27

[...]

cat ./aci-trip-meeting-point/aci-manifest.yml---name: aci.blbl.cr/aci-trip-meeting-point:{{.version}}aci: dependencies: - aci.blbl.cr/aci-java:1.8.181-2[...]

cat ./aci-java/aci-manifest.yml---name: aci.blbl.cr/aci-java:1.8.181-2aci: dependencies: - aci.blbl.cr/aci-debian:9.5-9 - aci.blbl.cr/aci-common:7

trip-meeting-point

aci-java

aci-debian aci-common

aci-trip-meeting-point aci-go-synapse aci-go-nerve aci-logshipper

aci-hindsight

Page 14: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Volatile - When should I redeploy?

A change in my own app/container: “immutable”

Noisy neighbours: “mutualization”

A change on a sidecar container or its dependencies

When you are ready for instability your are HA

Page 15: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

How?

Page 16: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Infrastructure Ecosystem

bare-metal servers

1 type of hardware

3 disk profiles

fleet cluster

CoreOS

ggn“Distributed init system”

Hardware

Container Registry

etcd

dgr

Service Codebase

rkt PODs

build

run

store

host

create mysqld

monitoring

nerve

mysql-main1

php

nginx

nerve

monitoring

synapse

front1

synapse

nerve

zookeeper Service Discovery

Page 17: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Infrastructure Ecosystem

bare-metal servers 1 type of hardware

3 disk profiles

fleet

CoreOS

ggn“Distributed init system”

Hardware

Container Registry

etcd

dgr

Service Codebase

rkt PODs

build

run

store

host

create mysqld

monitoring

nerve

mysql-main1

php

nginx

nerve

monitoring

synapse

front1

synapse

nerve

zookeeper Service Discovery

kuberneteshelm

Page 18: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

backend pod

client pod

Service Discovery

/database/node1

go-nerve does health checks and reports to zookeeper in

service keys

node1

/database

Applications hit their local haproxy to access backends

go-synapse watches zookeeper service keys and reloads haproxy if changes are

detected

HAProxy

go-nerve

Zookeeper

go-synapse

Page 19: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Stateful Services into containersMariaDB as an example

Page 20: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

“Stateful” and “volatile by design”?

Page 21: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

The recipe/prereqs/pillars to succeed:

Be Quiet!“A node should be able

to restart without impacting the app”

Abolish Slavery “For a given service, every node have the

same role”

Build Smart“Services can be

operate by any SRE”

Page 22: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

MariaDB as an example

Page 23: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Abolish Slavery “For a given service, every node

have the same role”

Page 24: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Asynchronous vs. Synchronous

Master

Slave Slave Slave

wsrep wsrep wsrep wsrep

MariaDB Cluster

wsrep

MariaDB Cluster means

No Single Point of Failure

No Replication Lag

Auto States Transfers

As fast as the slowest

Page 25: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

The Target

wsrep wsrep wsrep wsrep

MariaDB Cluster

wsrep

MariaDB Cluster

Containers

Writes go on one node

Writes

Reads are balanced on the others

Reads

Page 26: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

How to hit the target?Service Discovery

Page 27: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

# zookeepercli -c lsr /services/mysql/mainmysql-main1_192.168.1.2_ba0f1f8bmysql-main2_192.168.1.3_734d63damysql-main3_192.168.1.4_dde45787# zookeepercli -c get /services/mysql/main/mysql-main1_192.168.1.2_ba0f1f8b3{ "available":true, "host":"192.168.1.2", "port":3306, "name":"mysql-main1", "weight":255, "labels":{ "host":"r10-srv4" }}

# cat env/prod-dc1/services/mysql-main/attributes/nerve.yml---override: nerve: services: - name: "mysql-main" port: 3306 reporters: - {type: zookeeper, path: /services/mysql/main} checks: - type: sql driver: mysql datasource: "local_mon:local_mon@tcp(127.0.0.1:3306)/"

Nerve - Track and report service status

Page 28: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

# cat env/prod-dc1/services/tripsearch/attributes/tripsearch.yml—-override: tripsearch: database: read: host: localhaproxy database: tripsearch user: tripsearch_rd port: 3307 write: host: localhaproxy database: tripsearch user: tripsearch_wr port: 3308

Synapse  -  Service discovery router# cat env/prod-dc1/services/tripsearch/attributes/synapse.yml---override: synapse: services: - name: mysql-main_read path: /services/mysql/main port: 3307 - name: mysql-main_write path: /services/mysql/main port: 3308 serverOptions: backup serverSort: date

Page 29: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Be Quiet!“A node should be able to

restart without impacting the app”

Page 30: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

# cat env/prod-dc1/services/mysql-main/attributes/nerve.yml---override: nerve: services: - name: "mysql-main" port: 3306 reporters: - {type: zookeeper, path: /services/mysql/main} checks: - type: sql driver: mysql request: "SELECT 1" datasource: "local_mon:local_mon@tcp(127.0.0.1:3306)/"

Nerve - “Readiness Probe”

mysql -h 127.0.0.1 -ulocal_mon -plocal_mon -p3306 -e ‘SELECT 1;’

Starting Pod mysql-main1Nerve check is KO

Starting MySQLNerve check is KO

MySQL is syncing (IST/SST)Nerve check is KO

MySQL is readyNerve check is OK

Page 31: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

# cat env/prod-dc1/services/mysql-main/attributes/nerve.yml---override: nerve: services: - name: "mysql-main" port: 3306 reporters: - {type: zookeeper, path: /services/mysql/main} checks: - type: sql driver: mysql datasource: "local_mon:local_mon@tcp(127.0.0.1:3306)/" disableCommand: "/report_remaining_processes.sh" disableMaxDurationInMilli: 180000

Nerve - “Grace Period”

Wait

The remaining sessions are finishing their job

Pod Stopped

The service can be shutdown without risk.

Stop Pod

Call /disable on Nerve’s API

Set weight to 0 = no more new sessions will go into the services.

SELECT COUNT(1) FROM processlist WHERE user LIKE 'app_%';

Page 32: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Build Smart“Services can be operate by any SRE”

Page 33: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Use Service Discovery to find peersExample:

Page 34: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Use Service Discovery to find peers

Eg: the wsrep_cluster_address attribute in Galera Cluster

Description: The addresses of cluster nodes to connect to when starting up. Good practice is to specify all possible cluster nodes, in the form gcomm://<node1 or ip:port>,<node2 or ip2:port>,<node3 or ip3:port>. Specifying an empty ip (gcomm://) will cause the node to start a new cluster.

node1

mysql-main

node2 node3 node1

Ask the Service Discovery to find

mysql-main peers ?

No peer found!

wsrep_cluster_address = gcomm://

node2

node1

wsrep_cluster_address = gcomm://node1

node3

node1, node2

wsrep_cluster_address = gcomm://node1,node2

Page 35: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Next challenges Kubernetes, the Cloud

Page 36: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Kubernetes, the Cloud, why now?

Page 37: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Kubernetes, the Cloud, why now?

Fleet is deprecated

Fleet is no longer developed and maintained by CoreOS.

Kubernetes

From a simple “Distributed init

system” to the standard for container

orchestration.Docker

rkt-based implementation of Kubernetes has a poor adoption.

Page 38: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Service Oriented Architecture

Delegated Ownership.

Google Kubernetes Engine & Managed Services

Allows us to focus on services.

3 years old servers

We need to renew our hardware.

Kubernetes, the Cloud, why now?

Page 39: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Kubernetes and stateful services?

Page 40: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Kubernetes Statefulsets

Stable, unique network identifiers.

Stable, persistent storage.

Ordered, graceful deployment, scaling and rolling updates.

StatefulSets control Pods that are based on an identical spec.

Page 41: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Google Kubernetes Engine...

Page 42: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

Why are we excited about GKE?

Native suport of Liveness and Readiness probes

Release granularity, from Pod to Deployment/Statefulset

Native Service Discovery (kube-proxy and Services)

GCEPersistentDisk provisioner to manage Persistent Volumes

This + resources limitations make powerfull orchestration

Page 43: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve

See you next year for 100% GKE Powered Carpooling !

Page 44: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve
Page 45: Carpooling 100% Containers Powered · A change in my own app/container: “immutable” ... rkt PODs build run store host create mysqld monitoring nerve mysql-main1 php nginx nerve