provisioning & deploying with docker

29

Upload: eric-windisch

Post on 10-May-2015

1.456 views

Category:

Technology


0 download

DESCRIPTION

Using docker with configuration management. For all things Chef, presume I say "Puppet".

TRANSCRIPT

Page 1: Provisioning & Deploying with Docker
Page 2: Provisioning & Deploying with Docker

@ewindisch

Page 3: Provisioning & Deploying with Docker

Deploying with Docker

Atlanta Docker Meetup 2014.05.13

Page 4: Provisioning & Deploying with Docker

Do I still need Chef<or insert tool here>?

Page 5: Provisioning & Deploying with Docker

There is no easy answer

Page 6: Provisioning & Deploying with Docker
Page 7: Provisioning & Deploying with Docker
Page 8: Provisioning & Deploying with Docker

Why do we still need <or insert tool here>?

Page 9: Provisioning & Deploying with Docker

But… we have Dockerfiles!

Page 10: Provisioning & Deploying with Docker

It’s a shell-script?$ cat SomeApp/Dockerfile FROM ubuntu:13.10 RUN apt-get update; apt-get install apache RUN sed ’s/something/else/‘ /etc/apache/httpd.confADD shell-script.shRUN shell-script.shRUN [‘/usr/bin/apachectl’, ‘start’]

Page 11: Provisioning & Deploying with Docker

How do we do it?

$ cat Dockerfile FROM fedora RUN yum update \ yum -y install chef

Page 12: Provisioning & Deploying with Docker

Traditional Chef

Hardware

OS

Linux

Chef

Installs Chef

Runs

Configures

Page 13: Provisioning & Deploying with Docker
Page 14: Provisioning & Deploying with Docker

Images on HWis usually mutable

Hardware

Image

Linux

Chef

Installs Chef

Image'

Linux

Chef

Creates

Replaces

Runs

Page 15: Provisioning & Deploying with Docker
Page 16: Provisioning & Deploying with Docker

Ephemeral environmentsare (somewhat) immutable.

Hypervisor

Image

Linux

Chef

Runs

Image'

Linux

Chef

Chef

Runs

Configures

VM

Accesses

COW

Page 17: Provisioning & Deploying with Docker
Page 18: Provisioning & Deploying with Docker

Containers are like ephemeral VMs*

* Docker containers don’t HAVE to be ephemeral, but it’s TheRightThing

Docker

Image

Linux

Chef

Runs

Image'

Linux

Chef

Chef

Runs

Configures

Container

Accesses

COW

TM

Page 19: Provisioning & Deploying with Docker

Runtime Configuration

• One image, several configurations

• Configuration based on container environment

• Specify metadata or roles via environment variables (passed to ‘docker run -e’)

Page 20: Provisioning & Deploying with Docker

Chef-for-runtime

$ cat Dockerfile FROM fedora RUN yum update \ yum -y install chef

ADD http://x/receipes.tar.gz /opt/chef"ADD solo.rb /etc/chef/solo.rb"CMD chef-solo -c /etc/chef/solo.rb ; \! apachectl start

Page 21: Provisioning & Deploying with Docker

Does it converge?

$ docker build —rm . $ echo $? # pass or fail

(This is great use of Docker as an alternative to VMs for testing Chef recipes targeting non-Docker production systems)

Page 22: Provisioning & Deploying with Docker

Bootstrapping Configuration Management on every boot is expensive

Page 23: Provisioning & Deploying with Docker

Let us use images!

Page 24: Provisioning & Deploying with Docker

Build-time configuration

• Speed up Chef-based deployments (do it once!)

• Eliminate run-time network requirements

• Config-management CI

Page 25: Provisioning & Deploying with Docker

Chef-for-build

$ cat Dockerfile FROM fedora RUN yum update \ yum -y install chef"ADD http://x/receipes.tar.gz /opt/chef"ADD solo.rb /etc/chef/solo.rb"RUN chef-solo -c /etc/chef/solo.rb

Page 26: Provisioning & Deploying with Docker

Burning configurationinto images.

Docker ContainerInitiates Creates

Image

Linux

Chef

Chef

Runs

Configures

Build Creates

Page 27: Provisioning & Deploying with Docker

Expanded view: Burning configuration into images.

Docker Image tagInitiates

Image'

Linux

Chef

Chef

Build

Image

Linux

Chef

Creates

Creates

Runs Creates

References1

2

Page 28: Provisioning & Deploying with Docker

Anatomy of a Docker+Chef build & run

Docker ContainerInitiates Creates

Image

Linux

Chef

Chef

Runs

Configures

Chef

Runs

Configures

Build Creates

Stage 1 Stage 2

Page 29: Provisioning & Deploying with Docker

Chef-for-all-the-things$ cat Dockerfile FROM fedora RUN yum update \ yum -y install chef ADD http://x/receipes.tar.gz /opt/chef"ADD solo-stage1.rb /etc/chef/solo-stage1.rb"ADD solo-stage2.rb /etc/chef/solo-stage2.rb"RUN chef-solo -c /etc/chef/solo-stage1.rb"CMD chef-solo -c /etc/chef/solo-stage2.rb \;" apachectl start