baremetal deployment

74
Roberto Aguilar, [email protected] Dynamic, HA deployments with SaltStack & Docker @baremetalio

Upload: baremetal

Post on 15-Jan-2015

1.188 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Baremetal deployment

Roberto Aguilar, [email protected]

Dynamic, HA deployments with SaltStack & Docker

@baremetalio

Page 2: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

How many of us have:

Page 3: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Spent too much time deploying new software?

Page 4: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Spent too much time deploying new software?rolling back

Page 5: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Or have answered the question:

Page 6: Baremetal deployment

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Cassandra

Page 7: Baremetal deployment

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Memcached

Page 8: Baremetal deployment

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

RabbitMQ

Page 9: Baremetal deployment

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Redis

Page 10: Baremetal deployment

“Can we get an install of _________________ ?”

@[email protected] ⁃ ⁃ ⁃ ⁃

Page 11: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

With:

Page 12: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

–Your friendly devops / sysadmin

“maybe next week.”

Page 13: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

The answer should be:

Page 14: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

–Your friendly devops / sysadmin

“on it!”

Page 15: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

–Your friendly devops / sysadmin

“you can do it yourself!”

Page 16: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

How do we get there?

Page 17: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

“How to build a dynamic compute environment?”

Page 18: Baremetal deployment

@[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

@[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

@[email protected] ⁃ ⁃ ⁃ ⁃

Separation of concerns❖ Host systems are identical!

❖ Host systems are application/service -unaware!

❖ Services are self-contained

Page 21: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

The Application Layer

Page 22: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

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

Page 23: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

I. Codebase &

II. Dependencies

Page 24: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

V. Build, Release & Run

Page 25: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

IV. [Backing] Services

Page 26: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

VII. Port-binding

Page 27: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

III. Environment-based Config

Page 28: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Application Layer

service

serviceservice

servicedjango

rmqpg

cache

Django needs to be told how to access the services it depends on, which is done by passing in the connection information via environment variables

Page 29: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

The nuts and bolts

Page 30: Baremetal deployment

@[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

@[email protected] ⁃ ⁃ ⁃ ⁃

Application Environment

❖ Image creation!❖ Image distribution!❖ Application runtime

Page 32: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Fill in the blanks

Page 33: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

I. Codebase &

II. Dependencies

Page 34: Baremetal deployment

@[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

@[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

@[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

@[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

@[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

@[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

@[email protected] ⁃ ⁃ ⁃ ⁃

EXPOSE 80 443

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

II. Dependencies

Page 41: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

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

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

II. Dependencies

Page 42: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

V. Build, Release & Run

Page 43: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

docker run -d <image_name> [command]

Docker

Builds imagesdocker build -t <image_name> .

Container runtime

Page 44: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Docker Registrygithub.com/dotcloud/docker-registry

docker pull <image_name>

Host imagesdocker push <image_name>

Distribute images

Page 45: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Check out the Docker Index

http://index.docker.io

Ready-made, downloadable images

Page 46: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

Page 47: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

registry (optional)

Page 48: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

user (optional)

Page 49: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

service

Page 50: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Anatomy of an image name

registry.local/baremetal/postgresql

service

user (optional)

registry (optional)

Page 51: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

VII. Port-binding

Page 52: Baremetal deployment

@[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 53: Baremetal deployment

@[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

@[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

@[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

@[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

@[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 58: Baremetal deployment

@[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 59: Baremetal deployment

XII@[email protected] ⁃ ⁃ ⁃ ⁃

III. Environment-based Config

Page 60: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

pg

rmq

cache

III. Environment-based Config

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

amqp

://u

:p@

1.2.

3.35

:499

01

memcache://1.2.3.11:49302

django

Page 61: Baremetal deployment

@[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 POSTGRES_URL=postgres://u:[email protected]:49156/db \ registry.local/app1/djangoapp

III. Environment-based Config

Page 62: Baremetal deployment

@[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 63: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

import os

!

BROKER_URL = os.environ['AMQP_URL']

settings.py - RabbitMQ setup

III. Environment-based Config

Page 64: Baremetal deployment

@[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 65: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Orchestration

Page 66: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Orchestration Configuration❖ Repositories!

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

❖ repo, dependencies, failover, process type, node role!❖ Applications!

❖ services, # instances, configuration

Page 67: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

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

Page 68: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Container Daemon❖ Reacts to cluster events!❖ Reacts to Docker events for container uptime!

Page 69: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

What about Salt Master in a container?

Page 70: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Salt Master in a container

Why?

Page 71: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Salt Master in a container

❖ Self-contained!❖ Portable - simple to relocate to another system!❖ Easily test new salt version with !❖ Easy rollback if needed

Page 72: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Salt Master in a container

Issues

Page 73: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Salt Master in a container

❖ Are there scaling issues with Salt in a container?!❖ So far so good

Page 74: Baremetal deployment

@[email protected] ⁃ ⁃ ⁃ ⁃

Thanks!

Let us know what you think:

http://baremetal.io/saltconf