Upload
tareque-hossain
View
3.730
Download
1
Tags:
Embed Size (px)
DESCRIPTION
A presentation on django project deployment & update strategies. Presented at django-NOVA meetup on April 2nd, 2010
Citation preview
Deployment in the Cloud!
Tareque Hossain
Pony in the Cloud
Deployment Strategy
Cloud computing hosts (in our case Amazon EC2) supports dynamic instantiation of servers, which provides us the opportunity to maximize automation
To utilize the benefit, we automate our deployment 100% Key software packages become part of Amazon Machine Image
(AMI) e.g. MySQL, Apache, mod_wsgi, global Python runtimes, setuptools, search engines, version control systems etc.
All project specific packages are retrieved and installed at the time of deployment
Deployment StrategyContinued
Advantages of deployment time retrieval of project specific packages are: Ability to obtain most up to date package (with bug fixes) Minimize machine image size Use of public package distribution services (more clouds!)
But there are disadvantages: Public package distros don’t have guaranteed uptime Vulnerable to new bugs Security issues
Deployment Tools
At PBS we use the following tools for deployment: fabric, a Python library and command-line tool for
streamlining the use of SSH for application deployment or systems administration tasks
virtualenv, a tool to create isolated Python environments pip, a tool to install Python packages, a replacement of
easy_install git, the version control system we primarily use
Also involves writing some shell script
Deployment Procedure I
Instantiate a new server on the cloud (no details) Apache, MySQL, Python, setuptools & Git installed Check out project from git, and switch to project directory Execute a shell script bootstrap.sh, which we include in the
dist folder of our projects, which does the following: Install virtualenv if not already present Create a virtual environment for the deployment tools (since
different projects might depend on different versions) Install fabric
Shell Bootstrap Code
if [ -e fabfile.py ]; then if ! command -v virtualenv &>/dev/null; then
sudo easy_install virtualenv fi rm -Rf .ve.boot~/ virtualenv .ve.boot~/ .ve.boot~/bin/easy_install -q http://git.fabfile.org/cgit.cgi/fabric/snapshot/fabric-0.9b1.tar.gz .ve.boot~/bin/fab local bootstrap rm -Rf .ve.boot~/else echo "You must run this from your projects root directory."fi
Deployment Procedure II
Fabric looks for fabfile.py in the project root folder fabfile.py contains necessary server profiles & utility functions:
bootstrap, a function that accepts a server profile as argument and sets up the projects virtual environment
deploy, checks for deployment revision, which in our case is git tag, accepts revision number as input & updates the project
bootstrap_on_demand, a function that performs bootstrap only if the project environment is out of date
Fabric Code
Let us look at the fabric code.
Questions?
This presentation is available at: www.codexn.com Sample bootstrap.sh & fabfile.py are available for download