Your SlideShare is downloading. ×
  • Like
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH

  • 17,274 views
Published

Using Docker to bake configuration.

Using Docker to bake configuration.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
17,274
On SlideShare
0
From Embeds
0
Number of Embeds
35

Actions

Shares
Downloads
145
Comments
0
Likes
63

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Deploying
 with Docker DevOps Days PGH 2014.05.30 a.k.a. provisioning docker containers and images with Chef Deploying
 with Docker (or not)
  • 2. Why do we still need
 <insert tool here>?
  • 3. But… we have Dockerfiles!
  • 4. 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.conf
 
 ADD shell-script.sh
 RUN shell-script.sh
 
 RUN [‘/usr/bin/apachectl’, ‘start’]
  • 5. I ♥ #!/bin/bash . oo # https://raw.githubusercontent.com/
 # ewindisch/bashoo/master/lib/oo
 
 # Classes are created implicitly through functions
 function MsgWriter::new {
 self=$1; shift
 msg=$1; shift
 instance_var $self msg $msg 
 }
 function MsgWriter::write {
 self=$1; shift
 echo $($self.msg)
 }
 
 new terminal is MsgWriter “Hello World”
 terminal.write
  • 6. stack:~/devstack$ wc -l stack.sh functions 
 functions-common 
 lib/* lib/*/* | tail -n1 15490 total
  • 7. DevOps
 or crazy-sauce ?
  • 8. $ cd ~/rpm-chef
 $ cat Dockerfile
 FROM fedora
 RUN yum update 
 yum -y install chef DockerChef
  • 9. $ cd ~/omnibus-chef
 $ cat Dockerfile
 FROM fedora" RUN curl -L 
 https://www.opscode.com/chef/install.sh |
 /bin/bash DockerChef
  • 10. Traditional Chef Hardware OS Linux Chef Installs Chef Runs Configures
  • 11. Images on HW
 is usually mutable Hardware Image Linux Chef Installs Chef Image' Linux Chef Creates Replaces Runs
  • 12. Ephemeral environments
 are (somewhat) immutable. Hypervisor Image Linux Chef Runs Image' Linux Chef Chef Runs Configures VM Accesses COW
  • 13. 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
  • 14. Containers
 are
 THINGS
  • 15. X
  • 16. X
  • 17. Servers vs Things 
 Pets vs Cattle
  • 18. LET US 
 BAKE
 IMAGES! Let us BAKE images!
  • 19. 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
  • 20. Bakery Chef $ 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

  • 21. Burning configuration
 into images. Docker ContainerInitiates Creates Image Linux Chef Chef Runs Configures Build Creates
  • 22. Expanded view:
 Burning configuration into images. Docker Image tagInitiates Image' Linux Chef Chef Build Image Linux Chef Creates Creates Runs Creates References 1 2
  • 23. 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
  • 24. 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
  • 25. 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)
  • 26. Deploying Docker (for real this time)
  • 27. #!/bin/bash -x aws ec2 run-instances --image-id ami-e55a648c --key-name my-key --user-data "#include https://get.docker.io” 
 ip=$(aws ec2 describe-instances --output json --filter Name=instance-state-name,Values=running | python -c 'import json; import sys; print json.load(sys.stdin) [“Reservations”][0]["Instances"][0]["PublicIpAddress"]') 
 ssh ubuntu@$ip sudo docker run cirros
  • 28. # using https://github.com/bflad/chef-docker 
 $ cat cookbooks/docker-registry/default.rb
 # Pull latest image docker_image 'samalba/docker-registry' ! # Run container exposing ports docker_container 'samalba/docker-registry' do detach true port '5000:5000' env 'SETTINGS_FLAVOR=local' volume '/mnt/docker:/docker-storage' end
 
 $ knife ec2 server create # yada yada yada
  • 29. docker::run { 'helloworld':
 image => 'base',
 command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
 ports => ['4444', '4555'],
 links => ['mysql:db'],
 use_name => true,
 volumes => ['/var/lib/couchdb', '/var/log'],
 volumes_from => '6446ea52fbc9',
 memory_limit => 10485760, # bytes 
 username => 'example',
 hostname => 'example.com',
 env => ['FOO=BAR', 'FOO2=BAR2'],
 dns => ['8.8.8.8', '8.8.4.4'],
 restart_service => true,
 }
  • 30. Orchestration for Docker
 with OpenStack Heat DockerInc::Docker: :Container VMs Baremetal
  • 31. Heat Workflow Heat API VM Docker NovaNova resource Docker resource Container1 Container2 Container3 HOT
  • 32. heat_template_version: 2013-05-23 description: shared volumes example resources: my_instance: type: OS::Nova::Server properties: key_name: ewindisch_key image: ubuntu-precise flavor: m1.large user_data: #include https://get.docker.io ftp_container: type: DockerInc::Docker::Container properties: docker_endpoint: { get_attr: 
 [my_instance, first_address] } image: mikz/vsftpd
 ports: [ “21:21” ]
 volumes: [ “/ftp” ] name: “FTP”
 
 
 apache_container: type: DockerInc::Docker::Container properties: docker_endpoint: { get_attr: 
 [my_instance, first_address] } image: fedora/apache ports: [ “80:80” ] volumes-from: “FTP” cmd: “rm -rf /var/www; 
 ln -s /ftp /var/www;
 /run-apache.sh”
  • 33. Ansible - hosts: web
 sudo: yes
 tasks:
 - name: ensure redis container is running
 docker: image=crosbymichael/redis name=redis
 
 - name: ensure redis_ambassador container is running
 docker: image=svendowideit/ambassador 
 ports=6379:6379 links=redis:redis 
 name=redis_ambassador_ansible
  • 34. Mesos Flynn.io
  • 35. Creating Containers is Easy
  • 36. Managing them SUCKS needs improvement
  • 37. This is probably material for another talk…
  • 38. Container Inventory • discoverd / sdutil • serf • skydock • others?
  • 39. X
  • 40. X
  • 41. Q & A @ewindisch