complementing docker with puppet

27
Beyond Golden Containers Complementing Docker with Puppet David Lutterkort [email protected]

Upload: docker-inc

Post on 21-Nov-2014

121 views

Category:

Documents


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Complementing Docker with Puppet

Beyond Golden Containers Complementing Docker with Puppet

David Lutterkort  [email protected]

Page 2: Complementing Docker with Puppet

http://northshorekid.com/event/campfire-stories-marini-farm

Page 3: Complementing Docker with Puppet

http://www.partialhospitalization.com/2010/08/363/

Page 4: Complementing Docker with Puppet

lang en_US.UTF-8 keyboard us … rootpw --iscrypted $1$uw6MV$m6VtUWPed4SqgoW6fKfTZ/ part / --size 1024 --fstype ext4 --ondisk sda !repo --name=fedora —mirrorlist=… repo --name=updates —mirrorlist=… !%packages @core %end !%post curl http://example.com/the-script.pl | /usr/bin/perl !

What’s that machine doing ?

4

Page 5: Complementing Docker with Puppet

5http://www.gcksa.com/en/

Page 6: Complementing Docker with Puppet

6http://grillingwithrich.com/wrapping-meats-the-positives-and-negatives-and-everything-in-between/foil-ball

Page 7: Complementing Docker with Puppet

Overview

• Puppet  from  10,000  feet  • Managing  the  host  • Building  images  – without  a  master  (puppet apply)  – with  a  master  (puppet agent)  

• Run9me  configura9on

7

Page 8: Complementing Docker with Puppet

Infrastructure as Code

8

1)DEFINE 2)SIMULATE

4)REPORT 3)ENFORCE

Re-usable infrastructure-as-code

Insight into changes

Before deploying changes

Automatically and reliably

Page 9: Complementing Docker with Puppet

Dataflow in Puppet

9

Page 10: Complementing Docker with Puppet

class webserver { package { 'httpd': ensure => latest } -> file { '/etc/httpd/conf.d/local.conf': ensure => file, mode => 644, source => 'puppet:///modules/httpd/local.conf', } -> service { 'httpd': ensure => running, enable => true, subscribe => File['/etc/httpd/conf.d/local.conf'], } !}

A basic manifest

10

Page 11: Complementing Docker with Puppet

class webserver2 inherits webserver { File['/etc/httpd/conf.d/local.conf'] { source => 'puppet:///modules/httpd/other-local.conf', } }

Override via inheritance

11

Page 12: Complementing Docker with Puppet

The site-wide manifest

12

node host1.example.com { class { 'webserver': } } !node host2.example.com { class { 'webserver2': } } !node host3.example.com { class {'mongodb::server': port => 27018 } }

Page 13: Complementing Docker with Puppet

13

Page 14: Complementing Docker with Puppet

Overview

• Puppet  from  10,000  feet  • Managing  the  host  • Building  images  – without  a  master  (puppet apply)  – with  a  master  (puppet agent)    

• Run9me  configura9on

14

Page 15: Complementing Docker with Puppet

Managing the host

Gareth  Rushgrove’s  module:            hKps://forge.puppetlabs.com/garethr/docker  !

• Install  docker  (Ubuntu  and  CentOS)  • Manage  images  • Run  containers

15

Page 16: Complementing Docker with Puppet

!class { 'docker': tcp_bind => 'tcp://127.0.0.1:4243', socket_bind => 'unix:///var/run/docker.sock', }

Setting up Docker

16

Page 17: Complementing Docker with Puppet

!docker::image { 'ubuntu': image_tag => 'precise' }

Pulling down images

17

Page 18: Complementing Docker with Puppet

!docker::run { 'appserver2': image => 'fedora:20', command => '/usr/sbin/init', ports => ['80', '443'], links => ['mysql:db'], use_name => true, volumes => ['/var/lib/couchdb', '/var/log'], volumes_from => 'appserver1', memory_limit => 10485760, # bytes username => 'appy', hostname => 'app2.example.com', env => ['FOO=BAR', 'FOO2=BAR2'], dns => ['8.8.8.8', ‘8.8.4.4'] }

Running containers

18

Page 19: Complementing Docker with Puppet

Overview

• Puppet  from  10,000  feet  • Managing  the  host  • Building  images  – without  a  master  (puppet apply)  – with  a  master  (puppet agent)  

• Run9me  configura9on

19

Page 20: Complementing Docker with Puppet

Dockerfile for puppet apply

20

FROM jamtur01/puppetbase MAINTAINER James Turnbull <[email protected]> ADD modules /tmp/modules RUN yum -y install puppet; \ puppet apply --modulepath=/tmp/modules \ -e "class { 'nginx': service_ensure => disable }”EXPOSE 80 CMD ["nginx"]

Page 21: Complementing Docker with Puppet

Overview

• Puppet  from  10,000  feet  • Managing  the  host  • Building  images  – without  a  master  (puppet apply)  – with  a  master  (puppet agent)  

• Run9me  configura9on

21

Page 22: Complementing Docker with Puppet

!FROM fedora:20 MAINTAINER David Lutterkort <[email protected]> ADD puppet /tmp/puppet-docker RUN yum -y install puppet; \ yum clean all; \ /tmp/puppet-docker/bin/puppet-docker

Dockerfile for puppet agent

22

Page 23: Complementing Docker with Puppet

> tree puppet !puppet/ ├── bin │ └── puppet-docker ├── config.yaml └── ssl ├── agent-cert.pem ├── agent-private.pem ├── agent-public.pem └── ca.pem !

Support files

23

Page 24: Complementing Docker with Puppet

> cat puppet/config.yaml !--- certname: docker # server: puppet-master.example.com facts: container: docker build: true !

Configure agent run

24

Page 25: Complementing Docker with Puppet

Overview

• Puppet  from  10,000  feet  • Managing  the  host  • Building  images  – without  a  master  (puppet apply)  – with  a  master  (puppet agent)  

• Run<me  configura<on

25

Page 26: Complementing Docker with Puppet

Runtime configuration

• Install  an  init  system  (systemd)  – run  cron  or  puppetd  – run  target  service(s)  

• Possibly  move  to  one  agent  per  host

26

Page 27: Complementing Docker with Puppet

Summary

• Explain  what  you  are  doing  clearly  (or  scare  those  trying  to  understand  you  to  death)    

• Manage  container  hosts  with        hKps://forge.puppetlabs.com/garethr/docker  

• Sample  materials  for  puppet agent  etc.  at        hKps://github.com/luKer/puppet-­‐docker  

!

27

Ques9ons  ?