O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Continuous Delivery: The Next Frontier

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio

Confira estes a seguir

1 de 57 Anúncio

Continuous Delivery: The Next Frontier

Code testing and Continuous Integration are just the first step in a source code to production process. Combined with infrastructure-as-code tools such as Puppet the whole process can be automated, and tested!

Code testing and Continuous Integration are just the first step in a source code to production process. Combined with infrastructure-as-code tools such as Puppet the whole process can be automated, and tested!

Anúncio
Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (20)

Anúncio

Semelhante a Continuous Delivery: The Next Frontier (20)

Mais de Carlos Sanchez (15)

Anúncio

Mais recentes (20)

Continuous Delivery: The Next Frontier

  1. 1. CONTINUOUS DELIVERY, THE NEXT FRONTIER Carlos Sanchez @csanchez http://csanchez.org http://maestrodev.com
  2. 2. @csanchez Apache Maven ASF Member Eclipse Foundation csanchez.org
  3. 3. How we got here
  4. 4. Agile planning iterative development continuous integration release soon, release often
  5. 5. Fear of change Risky deployments It works on my machine! Siloisation Dev Change vs. Ops stability
  6. 6. Continuous Delivery
  7. 7. Continuous delivery
  8. 8. Infrastructure as Code it’s all been invented, now it’s standardized
  9. 9. package { 'openssh-server': ensure => present, } infrastructure IS code
  10. 10. service { 'ntp': name => 'ntpd', ensure => running, } declarative model state vs process no scripting
  11. 11. Follow development best practices tagging branching releasing dev, QA, production new solutions new challenges
  12. 12. Containers & Micro Services
  13. 13. Scale high availability distributed apps Google starts 20billion containers per week
  14. 14. But it is not trivial
  15. 15. Service oriented think about services, not machines
  16. 16. Docker Linux containers AUFS File System Users Processes Network
  17. 17. Docker Linux required but Boot2Docker to the rescue OS X Windows
  18. 18. Docker Runs anywhere! Bare metal Virtual Machines Cloud Docker
  19. 19. Docker delivery App System Docker image Docker infrastructure
  20. 20. Docker Registry Huge repository with pre-made images PostgreSQL Tomcat Java NodeJS Jenkins … Multiple versions and configurations tags
  21. 21. Docker for CD Developer environments CI dynamic build and test slaves
  22. 22. Docker docker run -t -i ubuntu /bin/bash docker ps -a docker build -t csanchez/test .
  23. 23. Vagrant
  24. 24. Vagrant Virtual and cloud automation VirtualBox VMWare Fusion AWS Rackspace Easy Puppet and Chef provisioning Keep VM configuration for different projects Share boxes and configuration files across teams base box + configuration files
  25. 25. Vagrant base boxes www.vagrantbox.es puppet-vagrant-boxes.puppetlabs.com anywhere! just (big) files
  26. 26. using Vagrant $ gem install vagrant $ vagrant box add centos-6.0-x86_64 http://dl.dropbox.com/u/1627760/centos-6.0-x86_64.box $ vagrant init myproject $ vagrant up $ vagrant ssh $ vagrant suspend $ vagrant resume $ vagrant destroy
  27. 27. Vagrant Vagrant.configure("2") do |config| # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "CentOS-6.4-x86_64-minimal" config.vm.box_url = "https://.../CentOS-6.4-x86_64-minimal.box" # web server config.vm.define :www do |config| config.vm.hostname = "www.acme.local" config.vm.network "forwarded_port", guest: 80, host: 10080 config.vm.network "private_network", ip: "192.168.33.12" end config.vm.provision :puppet do |puppet| puppet.module_path = "modules" puppet.manifest_file = "site.pp" end end
  28. 28. Packer
  29. 29. Packer Immutable infrastructure http://packer.io
  30. 30. Packer One definition multiple outputs VirtualBox VM Vagrant BOX EC2 AMI GCE image Docker image …
  31. 31. using Packer { "builders": [ { "type": "virtualbox-ovf", "source_path": "{{user `home`}}/.vagrant.d/boxes/centos-65-x64-virtualbox-nocm/ virtualbox/box.ovf", "ssh_username": "vagrant", "ssh_password": "vagrant", "shutdown_command": "echo 'packer' | sudo -S shutdown -P now" }, { "type": "googlecompute", "bucket_name": "maestrodev-images", "source_image": "centos-6-v20140718", "zone": "us-central1-a", "image_name": "centos-6-v20140718-2-puppet", "ssh_username": "support" } ], "provisioners": [ { "type": "shell", "inline": [ "sudo rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release- 6-10.noarch.rpm", "sudo yum install puppet-3.6.2 facter-1.7.6 -y" ] } ], "post-processors": [{ "type": "vagrant", "only": [ "virtualbox-ovf" ]}] }
  32. 32. Examples
  33. 33. Docker Infrastructure Jenkins Archiva www nginx tomcat1 tomcat db postgres
  34. 34. Docker images jwilder/nginx-proxy csanchez/appfuse-tomcat postgres
  35. 35. Building the application is not enough war Dockerfile docker image
  36. 36. appfuse-tomcat appfuse war jdbc driver tutum/tomcat:8.0 sql
  37. 37. appfuse-tomcat Dockerfile FROM tutum/tomcat:8.0 ENV WEBAPP_HOME $CATALINA_HOME/webapps/ROOT RUN apt-get update && apt-get install -y unzip curl postgresql RUN rm -rf $CATALINA_HOME/webapps/ROOT ENV REPO http://192.168.192.46:8000/repository/snapshots/ ENV VERSION 2.2.2-SNAPSHOT # Get the war RUN curl -sSL -o /tomcat/webapps/ROOT.war $REPO/org/appfuse/appfuse-spring/$VERSION/appfuse-spring-$ VERSION.war && mkdir -p $CATALINA_HOME/webapps/ROOT && cd $CATALINA_HOME/webapps/ROOT && unzip ../ROOT.war && rm ../ROOT.war # get the postgresql jdbc jar RUN curl -sSL -o $WEBAPP_HOME/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar http://repo1.maven.org/ maven2/postgresql/postgresql/9.1-901.jdbc4/postgresql-9.1-901.jdbc4.jar # configure the db connection and copy sql init file COPY jdbc.properties $WEBAPP_HOME/WEB-INF/classes/ COPY dump.sql / COPY run.sh /
  38. 38. run.sh #!/bin/bash if [ ! -f /.tomcat_admin_created ]; then /create_tomcat_admin_user.sh fi psql -U postgres -h db postgres < / dump.sql exec ${CATALINA_HOME}/bin/catalina.sh run
  39. 39. Docker build docker build -t csanchez/appfuse-tomcat docker/tomcat
  40. 40. Continuous Delivery commit git repo developer post commit hook jenkins build war & docker image binary repository integration testing db tomcat* www
  41. 41. Running Docker docker run -d --name db -p 5432:5432 postgres:8.4.22 docker run -d --name nginx -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy sleep 10 # wait for postgres to be up docker run -d --name tomcat -p 8081:8080 --link db:db -e TOMCAT_PASS=admin -e VIRTUAL_HOST=docker.local -e VIRTUAL_PORT=8080 csanchez/appfuse-tomcat
  42. 42. Infrastructure testing with Beaker
  43. 43. Puppet Labs Beaker Test deployments on real VMs, Docker containers, Cloud providers Use serverspec for assertions
  44. 44. Serverspec describe package('httpd') do it { should be_installed } end describe service('httpd') do it { should be_enabled } it { should be_running } end describe port(80) do it { should be_listening } end describe file('/etc/httpd/conf/httpd.conf') do it { should be_file } its(:content) { should match /ServerName www.example.jp/ } end
  45. 45. spec/acceptance/nodesets/default.yml HOSTS: centos-65-x64: roles: - master platform: el-6-x86_64 image: devopsil/puppet:3.5.1 hypervisor : docker docker_image_commands: - yum -y install tar - useradd vagrant CONFIG: log_level: debug type: git
  46. 46. spec/acceptance/nodesets/default.yml require 'spec_helper_acceptance' describe 'webapp' do describe port(80), :node => only_host_with_role(:webapp) do it { should be_listening } end end
  47. 47. End to End testing with Cucumber & Capybara
  48. 48. Cucumber Allows defining natural language
  49. 49. Capybara Runs Web tests using lower level APIs Webdriver/Selenium Poltergeist supports JavaScript headless
  50. 50. features/smoke_tests.feature @smoke_tests Feature: Smoke tests Smoke testing scenarios to make sure all system components are up and running. Scenario: Services should be up and listening to their assigned port * services should be listening on ports: | 80 | apache | | 8080 | tomcat | | 5432 | postgresql | Scenario: Appfuse is up and listening on port 80 Given I am at the "/login" page Then I should see the text "Sign In"
  51. 51. Example code and slides Available at http://slideshare.csanchez.org https://github.com/carlossg/continuous-delivery http://blog.csanchez.org
  52. 52. Danke! http://csanchez.org carlos@apache.org @csanchez
  53. 53. Photo Credits Brick wall - Luis Argerich http://www.flickr.com/photos/lrargerich/4353397797/ Agile vs. Iterative flow - Christopher Little http://en.wikipedia.org/wiki/File:Agile-vs-iterative-flow.jpg DevOps - Rajiv.Pant http://en.wikipedia.org/wiki/File:Devops.png Pimientos de Padron - Howard Walfish http://www.flickr.com/photos/h-bomb/4868400647/ Compiling - XKCD http://xkcd.com/303/ Printer in 1568 - Meggs, Philip B http://en.wikipedia.org/wiki/File:Printer_in_1568-ce.png Relativity - M. C. Escher http://en.wikipedia.org/wiki/File:Escher%27s_Relativity.jpg Teacher and class - Herald Post http://www.flickr.com/photos/heraldpost/5169295832/ Containers - Global Logistics Media http://www.globallogisticsmedia.com/articles/view/primitive-container-transportation-you-wont-believe Docker build ship run http://blog.docker.com/2014/06/announcing-docker-hub-and-official-repositories/

×