beyond golden containers
play

Beyond Golden Containers Complementing Docker with Puppet David - PowerPoint PPT Presentation

Beyond Golden Containers Complementing Docker with Puppet David Lutterkort @lutterkort lutter@puppetlabs.com What's that container doing ? FROM fedora:20 FROM fedora:20 MAINTAINER scollier <scollier@redhat.com> MAINTAINER scollier


  1. Beyond Golden Containers Complementing Docker with Puppet David Lutterkort @lutterkort lutter@puppetlabs.com

  2. What's that container doing ? FROM fedora:20 FROM fedora:20 MAINTAINER scollier <scollier@redhat.com> MAINTAINER scollier <scollier@redhat.com> RUN yum -y update && yum clean all RUN yum -y update && yum clean all RUN yum -y install couchdb && yum clean all RUN yum -y install couchdb && yum clean all RUN sed \ RUN sed \ -e 's/^bind_address = .*$/bind_address = 0.0.0.0/' \ -e 's/^bind_address = .*$/bind_address = 0.0.0.0/' \ -i /etc/couchdb/default.ini -i /etc/couchdb/default.ini ADD local.ini /etc/couchdb/local.ini ADD local.ini /etc/couchdb/local.ini EXPOSE 5984 EXPOSE 5984 CMD ["/bin/sh", "-e", "/usr/bin/couchdb", CMD ["/bin/sh", "-e", "/usr/bin/couchdb", "-a", "/etc/couchdb/default.ini", "-a", "/etc/couchdb/default.ini", "-a", "/etc/couchdb/local.ini", "-a", "/etc/couchdb/local.ini", "-b", "-r", "5", "-R"] "-b", "-r", "5", "-R"]

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

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

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

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

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

  8. Dataflow in Puppet

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

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

  11. The site-wide manifest node host1.example.com { node host1.example.com { class { 'webserver': } class { 'webserver': } } } node host2.example.com { node host2.example.com { class { 'webserver2': } class { 'webserver2': } } } node host3.example.com { node host3.example.com { class {'mongodb::server': class {'mongodb::server': port => 27018 port => 27018 } } } }

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

  13. Managing the host Gareth Rushgrove’s module: htups://forge.puppetlabs.com/garethr/docker • Install docker • Manage images • Run containers • Version 2.0.0 just released

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

  15. Pulling down images docker::image { 'ubuntu': docker::image { 'ubuntu': image_tag => 'precise' image_tag => 'precise' } }

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

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

  18. Dockerfile for puppet apply FROM fedora:20 FROM fedora:20 MAINTAINER James Turnbull <james@lovedthanlost.net> MAINTAINER James Turnbull <james@lovedthanlost.net> ADD modules /tmp/modules ADD modules /tmp/modules RUN yum -y install puppet; \ RUN yum -y install puppet; \ puppet apply --modulepath=/tmp/modules \ puppet apply --modulepath=/tmp/modules \ -e "class { 'nginx': service_ensure => disable }”; \ -e "class { 'nginx': service_ensure => disable }”; \ rm -rf /tmp/modules rm -rf /tmp/modules EXPOSE 80 EXPOSE 80 CMD ["nginx"] CMD ["nginx"]

  19. Dockerfile for puppet agent FROM fedora:20 FROM fedora:20 MAINTAINER David Lutterkort <lutter@watzmann.net> MAINTAINER David Lutterkort <lutter@watzmann.net> ADD puppet /tmp/puppet-docker ADD puppet /tmp/puppet-docker RUN yum -y install puppet; \ RUN yum -y install puppet; \ /tmp/puppet-docker/bin/puppet-docker /tmp/puppet-docker/bin/puppet-docker

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

  21. Configure agent run > cat puppet/config.yaml > cat puppet/config.yaml --- --- certname: docker.example.com certname: docker.example.com server: puppet-master.example.com server: puppet-master.example.com facts: facts: container: docker container: docker build: true build: true

  22. Dockerfile for puppet agent FROM fedora:20 FROM fedora:20 MAINTAINER David Lutterkort <lutter@watzmann.net> MAINTAINER David Lutterkort <lutter@watzmann.net> ADD puppet /tmp/puppet-docker ADD puppet /tmp/puppet-docker RUN yum -y install puppet; \ RUN yum -y install puppet; \ /tmp/puppet-docker/bin/puppet-docker /tmp/puppet-docker/bin/puppet-docker

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

  24. Runtime configuration • Oneshot at container launch • Install an init system (systemd) – run cron or puppetd – run target service(s) • Possibly move to one agent per host

  25. Summary • Manage container hosts with htups://forge.puppetlabs.com/garethr/docker • Sample materials for puppet agent etc. at htups://github.com/lutuer/puppet-docker Questjons ?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend