opps i deployed it again-ploneconf2010

Download Opps I deployed it again-ploneconf2010

If you can't read please download the document

Upload: dylan-jay

Post on 24-May-2015

1.182 views

Category:

Technology


2 download

DESCRIPTION

Hostout integrates buildout and fabric into an extensible out of the box deployment system.

TRANSCRIPT

  • 1. Oops! I deployed it again New ways to get your app in the cloud Dylan Jay

2. You've written a web app And now you need a host 3. We want it to be easy 4. We want flexibility 5. We want it to be cheap 6. Options Type Providers Flexibility (Easy) Scalability Shared Few e.g. Webfaction ($14) Limited Choice (Control Panel) None AppEngine One Google (Free) No Choice (Launcher) Built in VPS Lots e.g. Slicehost ($20) Unlimited choice (DIY) DIY Cloud Few e.g. Rackspace ($11) Unlimited choice (DIY) DIY 7. Can you have your cake and eat it to? 8. Hostout (Fabric, buildout) & Silverlining 9. Code under development 10. Push vs Pull 11. Fabric > from fabric import api def host_type(): api.run('uname -s') $ fab -H localhost,linuxbox host_type 12. Buildout Workflow Get the buildout $ python bootstrap.py $ bin/buildout $ bin/myinstalledscript add recipes to buildout.cfg from pypi $ bin/buildout 13. Building myapp $ bin/buildout $ bin/paster serve src/myapp/myapp.ini 14. Useful recipes zc.recipe.egg download eggs and create scripts collective.recipe.command run shell commands collective.recipe.template make config files from templates zc.recipe.cmmi compile, make, install stuff isotoma.recipe.apache or any other useful shortcuts mr.developer manage source control 15. Hostout Is a buildout recipe to replicate a local buildout to many hosts (using fabric) 16. Why document it when you can code it? 17. Basic Hostout [buildout] parts = host1 [host1] recipe = collective.hostout host = 127.0.0.1:10022 fabfiles = fabfile.py option1 = buildout user = root password = root path = /var/host1 18. Command line $> bin/hostout host1 host_type $> bin/hostout host1 host2 host_type echo hello 19. Share your command < setup.py > entry_points = {'zc.buildout': ['default =pkg:Recipe',], 'fabric': ['fabfile = pkg.fabfile'] }, [host1] recipe = collective.hostout extends = pkg 20. Built in commands Run Sudo Deploy Predeploy Bootstrap platform dependent setupusers setowners Uploadeggs Uploadbuildout Buildout Postdeploy 21. Releasing eggs 1 hostoutversions.cfg during buildout 2 sdist with md5 for all develop eggs 3 fabric.api.put all hashed eggs (if needed) 1 Direct to egg cache 4 deployed.cfg with hashed versions pinned 5 Upload zip of buildout + includes 6 fabric.api.run( bin/buildout -c deployed.cfg ) 22. Hostout Get a production buildout To your develop.cfg buildout add... [myhost] recipe = collective.hostout extends = hostout.cloud hostout.ubuntu hosttype = rackspace key = myaccount secret = myapikey buildout = production.cfg $ bin/buildout $ bin/hostout myhost deploy 23. Hostout is modular collective.hostout Deploys buildout to any posix host. Needs IP and password hostout.ubuntu bootstraps ubuntu host for buildout hostout.cloud Creates node ready to be bootstrapped fabfiles = myfabfile.py add your own 24. Suggested layout buildout.cfg (extends = config/deploy.cfg config/devel.cfg) config/ base.cfg (extends = base.cfg) devel.cfg (extends = base.cfg) prod.cfg (extends = base.cfg) deploy.cfg (extends = base.cfg) [host1] buildout = production.cfg parts = instance1 25. User model [host1] user = {initial sudo user} buildout-user = {owns buildout files + pw-less login} effective-user = {owns var dir} buildout-group = {group owns both} 26. Extra Options include = {files to include in buildout zip} parts = {override parts} sudo-parts = {sudo bin/buildout install } pre-commands = {shell to sudo before} post-commads = {shell to sudo after} path = {location of buildout} 27. Deployment Hooks def predeploy(): domystuff api.env.hostout.super.predeploy() Calls that are overridable api.env.hostout.callmycommand() 28. hostout.supervisor Pre and post deployment stop and start bin/hostout host status bin/hostout host supervisorboot bin/hostout host start/stop/restart 29. hostout.cloud bin/hostout host create bin/hostout host destroy Predeploy hook to create if needed [host1] extends = hostout.cloud hostout.ubuntu hostout.supervisor hosttype = rackspace hostname = ploneplonk key = ${keys:rackspace_key} secret = ${keys:rackspace_secret} 30. Gotchas Eggs must be releasable. Ie need setuptools-git etc All files must be checked in locally Interactive commands get stuck 31. $ bin/hostout host deploy 32. Silverlining By Ian Bicking Create app layout/dir $ silver init myapp Install dependencies into dir $ cd app; bin/easy_install repoze.bfg Install your code into dir $ bin/python src/myapp/setup.py develop 33. Silverlining II Configure it Edit app.ini: runner = src/myapp/myapp.ini Create host $ silver create-node myhost $ silver setup-node myhost Deploy (rsync) $ silver update myapp --node myhost 34. Hostout vs. Silverlining Many deployers Checkin. Checkout. Buildout. deploy Hostout uses fabric Cross platform but more dependencies (pycrypto) Hostout is modular Package your own fabfiles to help others deploy Hostout is flexible helps professionals Buildout is powerful. No limit to building/installing. NoSQL etc. Buildout shares dl code 35. Silverlining vs. Hostout Silverlining is batteries included You don't need a production buildout Silverlining is known target platform means less variables to go wrong Familiar workflow Commandline vs cfg. 36. Thanks Dylan Jay http://www.pretaweb.com twitter: djay75 [email protected] Know plone, syd admin or pywebdev? - we're hiring 37. Photo Credits http://www.flickr.com/photos/benheine/4613609067/sizes/l/in/set-72157622547905358/ http://www.flickr.com/photos/stevedave/3444248057/sizes/o/ http://www.flickr.com/photos/rkbcupcakes/3409724942/sizes/o/ http://www.flickr.com/photos/irrational_cat/517564258/