Baremetal deployment scale

76
Roberto Aguilar, [email protected] Automated deployments with SaltStack & Docker @baremetalio

description

 

Transcript of Baremetal deployment scale

Page 1: Baremetal deployment scale

Roberto Aguilar, [email protected]

Automated deployments with SaltStack & Docker

@baremetalio

Page 2: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

How many of us have:

Page 3: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Spent too much time deploying new software?

Page 4: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Spent too much time deploying new software?rolling back

Page 5: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Or have answered the question:

Page 6: Baremetal deployment scale

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Cassandra

Page 7: Baremetal deployment scale

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Memcached

Page 8: Baremetal deployment scale

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

RabbitMQ

Page 9: Baremetal deployment scale

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Redis

Page 10: Baremetal deployment scale

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Page 11: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

With:

Page 12: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

–Your friendly devops / sysadmin

“maybe next week.”

Page 13: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

The answer should be:

Page 14: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

–Your friendly devops / sysadmin

“on it!”

Page 15: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

–Your friendly devops / sysadmin

“you can do it yourself!”

Page 16: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

How do we get there?

Page 17: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

“How to build a dynamic compute environment?”

Page 18: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Dynamic Compute Environment❖ Easily start and stop services!

❖ Experimentation with a low barrier to entry!

❖ Scale processes as needed!

❖ Unique, isolated application environments!

❖ Self-service

Page 19: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

serve serve serveserveserve serveserver server serverserverserver server

server server serverserverserver serverserver server serverserverserver server

Separation of concerns

server server serverserverserver server

serviceservice

serviceservice

serviceserviceservice

service

service

serviceservice

serviceservice

serviceservice

service

Page 20: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Separation of concerns❖ Host systems are identical!

❖ Host systems are application/service -unaware!

❖ Services are self-contained

Page 21: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

The Application Layer

Page 22: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

The Twelve-Factor App http://12factor.net

Page 23: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

I. Codebase &

II. Dependencies

Page 24: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

V. Build, Release & Run

Page 25: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

IV. [Backing] Services

Page 26: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

VII. Port-binding

Page 27: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

III. Environment-based Config

Page 28: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

serve serve serveserveserve serveserver server serverserverserver server

server server serverserverserver serverserver server serverserverserver server

server server serverserverserver server

Application Layer

serviceservice

serviceservice

serviceserviceservice

service

service

serviceservice

serviceservice

serviceservice

servicedjango

rmqpg

cache

Page 29: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

The nuts and bolts

Page 30: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Compute Environment

❖ The way to interact with systems!❖ Server provisioning!❖ Base software stack!❖ System configuration!

❖ logging (syslog config)!❖ networking (/etc/hosts, floating IPs, etc.)!❖ metrics collection

Page 31: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Application Environment

❖ Image creation!❖ Image distribution!❖ Application runtime

Page 32: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Fill in the blanks

Page 33: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

I. Codebase &

II. Dependencies

Page 34: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

[0][~/Projects/baremetal/containers/nginx(master)]

[berto@g6]$ find . -type f | grep -v .git

./Dockerfile

./files/etc/apt/nginx.pgp

./files/etc/apt/sources.list.d/nginx.list

./files/etc/nginx/nginx.conf

[…]

I. Codebasenginx service repo

Page 35: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Dockerfile (http://docs.docker.io/en/latest/use/builder/)

II. Dependencies

❖ FROM - Defines the base image: OS, version, etc.!

❖ ADD - Adds files to image!

❖ RUN - Commands to configure image!

❖ EXPOSE - Specifies exposed ports!

❖ ENV - Defines environment variables!

❖ VOLUME - Filesystem directories that are sharable!

❖ CMD - Default command to run when launched

Page 36: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

FROM ubuntu:quantal

MAINTAINER Roberto Aguilar [email protected]

!ADD files/etc/apt/nginx.pgp /etc/apt/nginx.pgp

ADD files/etc/apt/sources.list.d/nginx.list /etc/apt/sources.list.d/nginx.list

!RUN apt-key add /etc/apt/nginx.pgp

RUN apt-get update

RUN apt-get install -y nginx

!EXPOSE 80 443

CMD /usr/sbin/nginx -g 'daemon off;'

Dockerfile (http://docs.docker.io/en/latest/use/builder/)

II. Dependencies

Page 37: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

FROM ubuntu:quantal

MAINTAINER Roberto Aguilar [email protected]

Dockerfile (http://docs.docker.io/en/latest/use/builder/)

II. Dependencies

Page 38: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

ADD files/etc/apt/nginx.pgp /etc/apt/nginx.pgp

ADD files/etc/apt/sources.list.d/nginx.list /etc/apt/sources.list.d/nginx.list

Dockerfile (http://docs.docker.io/en/latest/use/builder/)

II. Dependencies

Page 39: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

RUN apt-key add /etc/apt/nginx.pgp

RUN apt-get update

RUN apt-get install -y nginx

Dockerfile (http://docs.docker.io/en/latest/use/builder/)

II. Dependencies

Page 40: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

EXPOSE 80 443

Dockerfile (http://docs.docker.io/en/latest/use/builder/)

II. Dependencies

Page 41: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

CMD /usr/sbin/nginx -g 'daemon off;'

Dockerfile (http://docs.docker.io/en/latest/use/builder/)

II. Dependencies

Page 42: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

V. Build, Release & Run

Page 43: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

docker run -d <image_name> [command]

Docker

Builds imagesdocker build -t <image_name> .

Container runtime

Page 44: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Docker Registrygithub.com/dotcloud/docker-registry

docker pull <image_name>

Host imagesdocker push <image_name>

Distribute images

Page 45: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Check out the Docker Index

http://index.docker.io

Ready-made, downloadable images

Page 46: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

Page 47: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

service

Page 48: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

user (optional)

Page 49: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

user/service (push to index)

Page 50: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

registry (optional)

Page 51: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

service

user (optional)

registry (optional)

Page 52: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

VII. Port-binding

Page 53: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

$ docker run -d -p 80 -p 443 registry.local/baremetal/nginx1052eb879f4e[…]!$ docker ps | chopCONTAINER ID IMAGE PORTS1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157->80/tcp!$ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t"

VII. Port-binding

Page 54: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

$ docker run -d -p 80 -p 443 registry.local/baremetal/nginx1052eb879f4e[…]!$ docker ps | chopCONTAINER ID IMAGE PORTS1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157->80/tcp!$ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t"

VII. Port-binding

Page 55: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

$ docker run -d -p 80 -p 443 registry.local/baremetal/nginx1052eb879f4e[…]!$ docker ps | chopCONTAINER ID IMAGE PORTS1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157->80/tcp!$ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t"

VII. Port-binding

Page 56: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

$ docker run -d -p 80 -p 443 registry.local/baremetal/nginx1052eb879f4e[…]!$ docker ps | chopCONTAINER ID IMAGE PORTS1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157->80/tcp!$ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t"

VII. Port-binding

Page 57: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

$ docker run -d -p 80 -p 443 registry.local/baremetal/nginx1052eb879f4e[…]!$ docker ps | chopCONTAINER ID IMAGE PORTS1052eb879f4e […]nginx 0.0.0.0:49155->443/tcp, 0.0.0.0:49157->80/tcp!$ alias chop="sed -e 's/ */|/g' | cut -d'|' -f 1,2,6 | column -s '|' -t"

VII. Port-binding

Page 58: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

baremetal@baremetal:~$ docker port 1052eb879f4e 4430.0.0.0:49155baremetal@baremetal:~$ docker port 1052eb879f4e 800.0.0.0:49157

VII. Port-binding

Page 59: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

VII. Port-binding

-p 80:80

All interfaces, dynamic host port-p 80

All interfaces, explicit host port

-p 192.168.42.147:80:80

Explicit interface, dynamic host port-p 192.168.42.147::80

Explicit interface, explicit host port

Page 60: Baremetal deployment scale

XII@[email protected] ⁃ ⁃ ⁃ ⁃

III. Environment-based Config

Page 61: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

pg

rmq

cache

III. Environment-based Config

postgresql://u:[email protected]:49156/db

amqp

://u

:p@

1.2.

3.35

:499

01

memcache://1.2.3.11:49302

django

Page 62: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

$ docker run -d \ -p 1.2.3.42::8000 \ -e MEMCACHED_URL=memcache://1.2.3.11:49302 \ -e AMQP_URL=amqp://u:[email protected]:49901 \ -e POSTGRESQL_URL=postgresql://u:[email protected]:49156/db \ registry.local/app1/djangoapp

III. Environment-based Config

Page 63: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

import osfrom urlparse import urlparse!backend = 'django.core.cache.backends.memcached.MemcachedCache'memcached_url = urlparse(os.environ['MEMCACHED_URL'])CACHES = { 'default': { 'BACKEND': backend, 'LOCATION': memcached_url.netloc, }}

settings.py - memcached setup

III. Environment-based Config

Page 64: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

import os

!

BROKER_URL = os.environ['AMQP_URL']

settings.py - RabbitMQ setup

III. Environment-based Config

Page 65: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

import dj_database_url

!

dj_db_config = dj_database_url.config()

if dj_db_config:

DATABASES['default'] = dj_db_config

settings.py - postgresql setup

III. Environment-based Config

Page 66: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Baremetal Platform

Page 67: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Baremetal Platform❖ Thin as possible!❖ Run the platform on the platform!

❖ Run as many services as possible in containers

Page 68: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Baremetal Platform❖ Two main components!

❖ container manager!❖ orchestration!

❖ Two major goals!❖ minimize downtime!❖ eliminate single point of failure

Page 69: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Container Manager❖ Starts containers assigned to the host!❖ Stops containers no longer assigned!❖ Restarts containers that should be running and die!❖ Restarts containers when service config changes

Page 70: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Orchestration❖ Aware of all hosts in cluster!❖ Reacts to hosts joining and leaving cluster!❖ Reacts to configuration changes!❖ Assigns containers to hosts

Page 71: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Orchestration Configuration❖ Repositories!

❖ tracks Docker image, git repo and branch!❖ Services!

❖ repo, dependencies, failover!❖ Applications!

❖ services, # instances, configuration, memory allocation

Page 72: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

The nuts and bolts

Page 73: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Additional Services❖ etcd - fault-tolerant configuration store!❖ serf - host discovery and message passing!❖ zfs - next-gen copy-on-write filesystem

Page 74: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Containerize as much as possible

Page 75: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Containerize as much as possible

❖ Run the platform on the platform!❖ Services remain self-contained!❖ Portable - simple to relocate to another system!❖ Easily deploy new versions and rollback if needed

Page 76: Baremetal deployment scale

@[email protected] ⁃ ⁃ ⁃ ⁃

Thanks!

Let us know what you think:

http://baremetal.io/scale