CSC/ECE 517 Fall 2013/ch1 1w09 hs: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(155 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Code Deployment and Release Management with Rails =
= Code Deployment and Release Management with Rails =


Code Deployment or [http://en.wikipedia.org/wiki/Software_deployment Software Deployment] and [http://en.wikipedia.org/wiki/Release_management Release management] with [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] can be done using various tools such as [http://en.wikipedia.org/wiki/Capistrano Capistrano], [http://en.wikipedia.org/wiki/Heroku Heroku], Mina, Vlad, Inploy etc. These automated tools are frameworks used to write and execute commands in parallel remote machines and thus ease the process of deployment and management of various applications.
Code Deployment or [http://en.wikipedia.org/wiki/Software_deployment Software Deployment] and [http://en.wikipedia.org/wiki/Release_management Release management] with [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] can be done using various tools such as [http://en.wikipedia.org/wiki/Capistrano Capistrano], [http://en.wikipedia.org/wiki/Heroku Heroku], AppFog, OpenShift, AWS, Cloud 66, Vlad, etc. These automated tools are frameworks used to write and execute commands in parallel remote machines and thus ease the process of deployment and management of various applications.


__TOC__
__TOC__


= Introduction =
= Introduction =


'''Deployment'''
The Deploying process involves different stages like development, testing, release management and sign-off by project teams.


Deployment is the process of transferring an application onto a production server to make it available for other users. This process involves various activities and transitions between them. Though the general guidelines for deployment remain the same, the specific requirements vary with each software system. Different deployment activities include release, install and activate, deactivate, adapt, update, built-in, version tracking, uninstall and retire.
The following diagram illustrates the deployment process of an application.


'''Release Management'''
[[File:Deployment Process.jpg|frame|center|<ref>http://technet.microsoft.com/en-us/library/cc465178.aspx</ref>]]


Release management is a software process which takes care of the development, testing, deployment and support stages of software releases. The start of release management happens in the development phase, where it requests for new features or changes in the existing. When the request is accepted, a new release is planned and designed. This design then enters the testing phase, where the release is built and tested until it is accepted. After the release is accepted as a candidate, it enters the deployment phase where it is implemented. Once deployed, the release is made available and sent to support phase for collection of bug reports. Once the support phase is done, the bugs and other issues lead to the requests for changes and the cycle is then repeated.


[[File:Deployment Process.jpg|thumb|Deployment Process]]
The deployment flow has three stages: development and testing, release management and stakeholders and project teams.  


= Why Automate Deployment =
After the final release of the code in development and testing stage, the master plan is prepared for deployment of components and sites based on the sign-offs provided by the project teams, stakeholders and customers. Then, the stabilization of the deployment is calculated based on some metrics. Once the deployment is stabilized, it is reviewed and the process of deployment is complete. The final sign-off is given by the stakeholders.


Automation of a process is required when the manual process is more error prone. Also, for large real world applications, the manual process is very complex and time consuming. The incomplete documentation add to the drawbacks of a manual process. The components require the deployment to be done in a specific order to many environments. Manual process needs repetition of same procedure to each and every environment which leads to many errors and the process becomes costly.
==Code Deployment==


Automation of deployment delivers applications faster and with fewer errors. The defined software deployment process can be applied across all environments consistently every time. With various automated application deployment platforms now readily available, manual deployments become a thing of the past.
Code deployment is a procedure where the application is transferred onto a production server, so that it is made available for all the other users. It is the part of release management process which involves several activities. These activities are inter-dependent and need to be completed in a specific order for successful code deployment.
 
'''Code Deployment Activities'''
 
The various deployment activities include <ref>http://en.wikipedia.org/wiki/Software_deployment</ref>
* Release : Gathering all system components in preparation for deployment
* Install and activate : Installing the application components and getting them in the 'ready' state
* Deactivate : Shutting down components that are out-dated or that may interfere with updating others
* Adapt : Making changes to application to accommodate changes in environment
* Update : Having a newer release installed in place of the old one
* Built-in : There are components built-into some tools for complete/semi-automating updates
* Version tracking : These systems help the user to know if newer versions of a software are available and if yes, help install them
* Uninstall : Opposite of installation and involves complete removal of software and its dependencies from the environment
* Retire : This involves making a software obsolete and is the end of software life cycle
 
The general guidelines for the deployment process remain the same but there are variations in the specific requirements with each software system.
 
==Release Management==
 
<ref>http://searchitchannel.techtarget.com/definition/release-management</ref>
Release management is a software process which takes care of the development, testing, deployment and support stages of software releases. The start of release management happens in the development phase, where it requests for new features or changes in the existing application. When the request is accepted, a new release is planned and designed. This design is built and then enters the testing phase, where the release is tested until it is accepted. After the release is accepted as a candidate, it enters the deployment phase where it is implemented. Once deployed, the release is made available and sent to support phase for collection of bug reports. Once the support phase is done, the bugs and other issues lead to requests for changes and the cycle is then repeated.
 
= Automating Code Deployment and Release Management =
<ref>http://www.urbancode.com/html/solutions/deployment-automation.html</ref>
Automation of a process is required when the manual process is more error prone. Also, for large real world applications, the manual process is very complex and time consuming. Incomplete documentation hampers a manual process further. Deployment also has to be done in many environments and involves varied steps to be followed in a specific order. Manual process needs repetition of same procedure to each and every environment which leads to many errors and the process becomes costly.
In web applications each new release has to be deployed to and tested in development, testing and production environments.The number of software releases in web applications  are more and hence the need to automate release management is also greater.
 
Automation of deployment delivers applications faster and with fewer errors. The defined software deployment process can be applied across all environments consistently every time. With various automated application deployment platforms now readily available, manual deployments have become a thing of the past.
 
Lets take a look at the various Deployment Automation tools available to Ruby on Rails applications. For the purposes of this article the process of manual deployment of a Ruby on Rails application is out of scope.


= Deployment Automation tools =
= Deployment Automation tools =
Line 30: Line 58:
* Heroku
* Heroku
* Vlad
* Vlad
 
* AppFog
Lets look at each of them in turn.
* AWS Elastic Beanstalk
* OpenShift
* Cloud 66


== Capistrano ==
== Capistrano ==


Capistrano is a Ruby program that gives you a set of advanced tools to deploy web applications to your servers. With Capistrano it’s also possible to deploy to many machines at once.
[[File:Capistrano.jpg|frame|right|<ref>http://www.capistranorb.com/</ref>|Capistrano Logo]]
Capistrano offers many advanced options and can be used to deploy many kinds of applications.


It supports the scripting and execution of arbitrary tasks, and includes a set of sane-default deployment workdflows.
Capistrano is a Ruby tool which helps deploy an application to the server. Capistrano allows deploying to multiple machines at a time. It has many advanced options which help to deploy different kinds of applications. It also supports the scripting and execution of tasks.


Capistrano can be used to:
Capistrano can be used to:


Reliably deploy web application to any number of machines simultaneously, in sequence or as a rolling set
* Deploy applications onto many machines simultaneously.
* To automate audits of any number of machines (checking login logs, enumerating uptimes, and/or applying security patches)
* Automate the audits
* To script arbitrary workflows over SSH
* Automate the common tasks of a team.
* To automate common tasks in software teams.
* To drive infrastructure provisioning tools such as chef-solo, Ansible or similar.


Capistrano is also very scriptable, and can be integrated with any other Ruby software to form part of a larger too.
Capistrano can be made a part of a larger software by integrating it with another Ruby software.


=== Installing Capistrano ===


<ref>http://www.capistranorb.com/documentation/getting-started/installation/</ref>  
'''General Usage'''
'''General Usage'''


The following commands will clone Capistrano at the latest v3 revision, and will build the gem and install it locally.
The following commands will clone Capistrano, build the gem and install it locally.
<pre>
<pre>
$ gem install capistrano --pre --trust-policy HighSecurity
$ gem install capistrano --pre --trust-policy HighSecurity
Line 93: Line 120:
== Heroku ==
== Heroku ==


Heroku is a cloud platform as a service (PaaS) supporting several programming languages. Heroku was acquired by Salesforce.com in 2010. Heroku, one of the first cloud platforms, has been in development since June 2007, when it supported only the Ruby programming language, but has since added support for Java, Node.js, Scala, Clojure and Python and (undocumented) PHP and Perl. The base operating system is Debian or, in the newest stack, the Debian-based Ubuntu.
[[File:Heroku.jpg|frame|right|<ref>https://www.heroku.com/</ref>|Heroku Logo]]


Heroku lets you manage environment-specific configurations (such as credentials for backing services) separately from your source code for greater safety and portability. In Heroku, this data can be managed with config vars, which are made available to your running application as simple environment variables.
Heroku is a cloud [http://en.wikipedia.org/wiki/Platform_as_a_service Platform as a Service] (PaaS) which supports several programming languages. PaaS is a service model of Cloud computing wherein the provider offers resources like servers, software, database, etc. to the developer. Heroku helps manage environment-specific configurations separately from the source code, which provides greater security.
Heroku is not just a deployment environment but it also impacts the development process. There are several principles of the development of application on Heroku.<br>
• Applications and Codebases : Most of the development of the application is done on application’s codebase which is stored in a [http://en.wikipedia.org/wiki/Version_control_system Version Control System (VCS)] <br>
• Dependencies : All the application dependencies such as plugins should be declared explicitly<br>
• Configuration : Configuration of an application is all that varies in different deploys<br>


'''Heroku CLI'''


The Heroku CLI is used to manage Heroku apps from the command line.
'''Getting Started with Heroku'''


Once installed, you'll have access to the heroku command from your command shell. Log in using the email address and password you used when creating your Heroku account:
1. To get started with Heroku, go to https://id.heroku.com/signup/devcenter, signup for a Heroku account.


2. Then, download and install the Heroku toolbelt at https://toolbelt.heroku.com/ for your development system. You can also use Heroku command line instead of the online Heroku application.
3. After installing one of them, login using the email address and password used when creating the Heroku account:
<ref>https://github.com/heroku/heroku</ref>
<pre>
<pre>
$ heroku login
$ heroku login
Line 114: Line 149:
</pre>
</pre>


'''Deploying Apllications'''
'''Deploying Applications'''
 
Heroku uses [http://en.wikipedia.org/wiki/Git_(software) git] primarily to deploy the applications. When an application is created on Heroku, it associates the new git which is remote with the local git repository.


The Heroku platform uses git as the primary means for deploying applications.
When you create an application on Heroku, it associates a new git remote, typically named heroku, with the local git repository for your application.
As a result, deploying code is just the familiar git push, but to the heroku remote instead:
As a result, deploying code is just the familiar git push, but to the heroku remote instead:
<ref>https://devcenter.heroku.com/articles/how-heroku-works#deploying-applications</ref>
<pre>
<pre>
$ git push heroku master
$ git push heroku master
Line 125: Line 162:
== Vlad ==
== Vlad ==


Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync.
[[File:Vlad.png|frame|right|<ref>http://rubyhitsquad.com/Vlad_the_Deployer.html</ref>|Vlad Logo]]
 
Vlad is another automated deployment tool which is simple to use. It integrates with rake and uses standard tools like SSH, rsync etc.
 
The main features of Vlad include
* It uses very few dependencies which are simple.
* It can execute commands on more than one server.
* It syncs files to one or more servers.
* It matches local and remote tasks.
* It runs tests very fast.
 
'''Getting started with Vlad'''<ref>http://docs.seattlerb.org/vlad/doco/getting_started_txt.html</ref>
 
Create a deploy file, usually in “config/deploy.rb”:
<pre>
set :application, "project"
set :domain, "example.com"
set :deploy_to, "/path/to/install"
set :repository, 'http://svn.example.com/project/branches/stable/'
</pre>
This defaults to using ‘svn export’ from repository, and a single server for app, db, and www.
 
If you want a multi-config environment, change your config like so:
<pre>
set :application, "project"
set :repository, 'http://svn.example.com/project/branches/stable/'
 
task :beta do
  set :domain,   "beta.example.com"
  set :deploy_to, "/path/to/install-beta"
end
 
task :dev do
  set :domain,    "dev.example.com"
  set :deploy_to, "/path/to/install-dev"
end
 
task :prod do
  set :domain,    "example.com"
  set :deploy_to, "/path/to/install"
end
</pre>
 
Add the following to your Rakefile:
<pre>
begin
  require 'vlad'
  Vlad.load
rescue LoadError
  # do nothing
end
</pre>
Vlad.load has a lot of flexibility.
 
You can install vlad via:
 
<pre>% rake vlad:invoke COMMAND='sudo gem install vlad -y'</pre>
 
Initial Launch
<pre>Run rake vlad:setup vlad:update vlad:migrate vlad:start</pre>
 
 
<ref>http://docs.seattlerb.org/vlad/index.html</ref>
'''Running Vlad'''
 
* Using rake
<pre>
task :shazam! do
  Rake::Task[:action1].invoke
  Rake::Task[:action2].invoke
end
</pre>
* Using SSH
<pre>
Host example.com
    User fluffy_bunny
</pre>
 
== AppFog ==
 
[[File:AppFog.jpg|frame|right|<ref>https://www.appfog.com/</ref>|AppFog Logo]]
 
AppFog is a PaaS built on Cloud Foundry which is another PaaS platform for deploying applications.
 
Features of AppFog are
* It launches and runs fast.
* It does not require configuring servers or installing frameworks.
* It is compatible with code management systems like git, svn etc.
 
'''Installing AppFog'''<ref>http://blog.appfog.com/getting-started-with-appfogs-command-line/</ref>
 
‘af‘ command line tool is written in Ruby for installation.
 
Download and install [http://rubyinstaller.org/ Ruby Installer] for Windows. The installer already includes RubyGems.
 
Be sure you use the Ruby-enabled command prompt window when you later install and use af. You access this command prompt from the Windows Start menu (All Programs > Ruby > Start Command Prompt with Ruby).


'''Features'''
Finally, update RubyGems from the Ruby Command Prompt:
<pre>
$ gem update --system
$ gem install af
</pre>
Login with:
<pre>
$ af login
</pre>
Finally from within your source code directory:
<pre>
$ af update hello-node
</pre>
 
'''Getting Started with AppFog'''
<pre>
target [url]                                      Reports current target or sets a new target
login [email] [--email, --password]                Login
info                                              System and account information
</pre>


* Full deployment automation stack.
== AWS Elastic Beanstalk==
* Turnkey deployment for passenger+apache+svn.
* Supports single server deployment with just 3 variables defined.
* Built on rake. Easy. Engine is small.
* Very few dependencies. All simple.
* Uses ssh with your ssh settings already in place.
* Uses rsync for efficient transfers.
* Run remote commands on one or more servers.
* Mix and match local and remote tasks.
* Compatible with all of your tab completion shell script rake-tastic goodness.
* Ships with tests that actually pass in 0.028 seconds!


= Comparison between Capistrano/Heroku/Vlad =
[[File:AWSLogo.jpg|frame|right|<ref>https://aws.amazon.com</ref>|AWS Logo]]
{| class="wikitable"
 
|-
Amazon Wen Services(AWS) offers [http://en.wikipedia.org/wiki/Infrastructure_as_a_service#Infrastructure_as_a_service_.28IaaS.29 Infrastructure as a Service] (IaaS) and provides a complete set of resources for the development of a web application in minutes. AWS Elastic Beanstalk is a deployment tool of the AWS cloud.
! style="width:10%;"|Criteria
 
! style="width:30%;"|Capistrano
With AWS Elastic Beanstalk, applications can be quickly deployed and managed in the AWS cloud without worrying about the infrastructure that runs those applications. AWS Elastic Beanstalk reduces management complexity without restricting choice or control. Once the application is uploaded AWS Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring. AWS Elastic Beanstalk uses highly reliable and scalable services.
! style="width:30%;"|Heroku
 
! style="width:30%;"|Vlad
'''AWS CLI'''
|- style="vertical-align:top;"
 
|<tt></tt>
AWS Elastic Beanstalk uses a command line tool Eb, which helps you to deploy your application easily.
|<tt><nowiki>"Take some more [[tea]]," the March Hare said to Alice, very earnestly.</nowiki><br /><br /><nowiki>"I've had '''</nowiki>nothing<nowiki>'''</nowiki> yet," Alice replied in an offended tone, "so I can't take more."<br /><br />"You mean you can't take <nowiki>'</nowiki>'less'<nowiki>'</nowiki>?" said the Hatter. "It's very easy to take <nowiki>'</nowiki>'more'<nowiki>'</nowiki> than nothing."</tt>
 
|<tt>&lt;p&gt;"Take some more <a title="Tea" href="/wiki/Tea">tea</a>," the March Hare said to Alice, very earnestly.&lt;/p&gt;<br /><br />
'''Getting Started with Eb'''<ref>http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-reference-get-started.html</ref>
&lt;p&gt;"I've had &lt;strong&gt;nothing&lt;/strong&gt; yet," Alice replied in an offended tone, "so I can't take more."&lt;/p&gt;<br /><br />
 
&lt;p&gt;"You mean you can't take &lt;em&gt;less&lt;/em&gt;?" said the Hatter. "It's very easy to take &lt;em&gt;more&lt;/em&gt; than nothing."&lt;/p&gt;
To get started with the beanstalk CLI, you will need to download the command line tools at the [http://aws.amazon.com/code/6752709412171743 AWS Sample Code & Libraries] website.
<br /></tt>
 
|"Take some more [[tea]]," the March Hare said to Alice, very earnestly.
Step 1: Initialize Your Git Repository
 
Eb is a command line interface that enables you to deploy applications quickly and more easily using Git. Eb is available as part of the Elastic Beanstalk command line tools package.
 
1. To install eb,install the following software onto your local computer:
 
* Git 1.6.6 or later. To download Git, go to http://git-scm.com/.
* PowerShell 2.0.
 
2. Initialize your Git repository.
<pre>
git init
</pre>
 
Step 2: Configuring AWS Elastic Beanstalk
 
1. From your directory where you created your local repository, type the following command.
<pre>
eb init
</pre>
 
2. When you are prompted for the access key ID, type your access key ID.
<pre>
Enter your AWS Access Key ID (current value is "AKIAIOSFODNN7EXAMPLE"):
</pre>
 
3. When you are prompted for the secret access key, type your secret access key.
<pre>
Enter your AWS Secret Access Key (current value is "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"):
</pre>
 
4. When you are prompted for the AWS Elastic Beanstalk application name, type the name of the application.
<pre>
Enter an AWS Elastic Beanstalk application name (auto-generated value is "windows"):
</pre>
Note:
If you have a space in your application name, make sure you do not use quotes.
 
5. When you are prompted for the AWS Elastic Beanstalk environment name, type the name of the environment. AWS Elastic Beanstalk automatically creates an environment name based on your application name. If you want to accept the default, press Enter.
<pre>
Enter an AWS Elastic Beanstalk environment name (current value is "HelloWorld-env"):
</pre>
 
6. When you are prompted to create an Amazon RDS DB instance, type y or n. For this example, we'll type y.
<pre>
Create an RDS DB Instance? [y/n]:
</pre>
 
7. When you are prompted to enter your RDS user master password, type your password containing from 8 to 16 printable ASCII characters (excluding /, \, and @).
<pre>
Enter an RDS DB master password:
Retype password to confirm:
</pre>
 
You can now get started with the AWS Elastic Beanstalk.
 
== OpenShift ==
 
[[File:OpenShift.png|frame|right|<ref>https://en.wikipedia.org</ref>|OpenShift Logo]]
 
Another free and open source PaaS for deploying applications is OpenShift created by [[http://en.wikipedia.org/wiki/RedHat RedHat]].
 
'''Considerations'''
* Databases
 
To use the application outside the OpenShift environment one needs to change the variables as the application is configured to use database in production mode in OpenShift.
 
* Assets
 
The assets are precompiled everytime application is pushed to OpenShift.
 
* Security
 
Security related variables are to be unique across the application.
<ref>https://github.com/openshift/rails-example</ref>
'''Installation'''
 
1. Create an account at http://openshift.redhat.com/
 
2. Create a rails application
<pre>rhc app create -a railsapp -t ruby-1.9</pre>
3. Add mysql support to your application
<pre>rhc cartridge add -a railsapp -c mysql-5.1</pre>
4. Add this upstream Rails quickstart repository
<pre>cd railsapp
git remote add upstream -m master git://github.com/openshift/rails-example.git
git pull -s recursive -X theirs upstream master</pre>
5. Push your new code
<pre>git push</pre>
 
== Cloud 66 ==
 
[[File:Cloud 66.jpg|frame|right|<ref>https://www.cloud66.com/</ref>|Cloud66 Logo]]
 
Cloud 66 combines the convenience of Platform-as-a-Service (PaaS) and the flexibility and control of Infrastructure-as-a-Service (IaaS). This platform allows easy deployment of application, so there is no overhead of configuring or monitoring the servers.
 
'''Cloud 66 Command line Toolbelt'''
 
Toolbelt is an open source released to deploy the application.
 
<ref>http://blog.cloud66.com/</ref>
 
'''Getting Started with Cloud 66'''


"I've had '''nothing''' yet," Alice replied in an offended tone, "so I can't take more."
1. Go to the [https://www.cloud66.com/users/sign_up sign up] page and create a Cloud 66 account.


"You mean you can't take ''less''?" said the Hatter. "It's very easy to take ''more'' than nothing."
2. Go to Cloud 66 Dashboard and [https://www.cloud66.com/help/first_stack build your first stack].
|}


= Conclusion =
'''Installation'''


We compare and contrast between various deployment automated tools such as Capistrano, Heroku and Vlad. Among the three tools, Vlad is the one of the newest tools which is highly automated and faster in deploying applications than the other tools. It is the highly pragmatic tool which automates the entire process of code deployment and release management with Rails.
Installation of toolbelt uses the following command


= References =
<pre>
Gem install c66
</pre>


http://technet.microsoft.com
This automatically searches the newest version and installs it.


http://searchitchannel.techtarget.com/definition/release-management
= Comparison between Capistrano/Vlad/Heroku/AppFog/OpenShift/Cloud66/AWS Beanstalk =


http://www.capistranorb.com/documentation/getting-started/installation/
With so many automated tools available for Code Deployment and Release Management, the decision on which to use for a particular Ruby on rails application depends on various parameters to be considered.
Some comparative features of the different tools are as follows :


http://www.urbancode.com/html/solutions/deployment-automation.html
{| class="wikitable"
|-
! style="width:9%;"|Criteria for Comparision
! style="width:13%;"|Capistrano
! style="width:13%;"| Vlad
! style="width:13%;"| Heroku
! style="width:13%;"| AppFog
! style="width:13%;"| OpenShift
! style="width:13%;"| Cloud66
! style="width:13%;"| AWS Beanstalk
|- style="vertical-align:top;"
|'''''Getting started with the tool'''''
|It is a framework that allows one to execute commands on a remote server using tools like ssh.
|Vlad deployment is similar to Capistrano, but less complex.
|Heroku’s offers a plan with first dyno free i.e. 512 MB that can be paired with Postgres starter DB to start an application with 0 initial cost
|AppFog’s initial plan offers 2GB of RAM free which is enough for small to medium traffic applications. By managing options provided for DB, queue server, application server, etc all part of the intial package, this is an excellent option to try out an application
|OpenShift is an open source platform and its free plan for starters has 3 gears for free wherein each gear consists of some RAM and disk space.
|Free plan provides one server for deployment.
|Provides an initial free tier. Without free tier no additional cost for Beanstalk. One only needs to pay for the AWS resources used.
|-
|'''''Scaling Memory'''''
|Memory increase would require additional servers/unused space in existing ones.
|Memory increase depends on additional servers available/unused space in existing ones.
|Memory increased in terms of dyno each of size 512 MB.
|Can configure any size for memory allocation
| -
| -
|Can automatically up/down scale the application by adjusting the default auto scaling settings.
|-
|'''''Scaling – Cost and Ease'''''
|While this provides greater flexibility as user is in control of the servers, it also causes additional overhead in terms of user needing to work both on Rails application and web server deployment.
|It can be integrated with Rake without any hindrances.
|Can dynamically scale up and down an application and pay as per hourly usages. Each additional dyno costs $35/mo
|Scaling takes up some time and need to pay for a month at the minimum. Scaling up to 4GB increases cost to $100/mo
| -
|Scaling using Cloud66 is relatively easy and hassle free.
|Scaling is fast and easy.
|-
|'''''Special features'''''
|For sensitive applications where handing over the control to a third party for deployment is not feasible, Capistrano is the way to go.
|It also provides support for tools like rsync and ssh.
|Lacks support for cross region deployment i.e. can’t select location of server where application gets deployed
|Supports cross region deployment i.e. if users of application primarily in Asia, can choose a server in Asia to deploy application, thus making the site faster.
| -
| -
|Provides complete flexibility and control of the resources to the user including the chance to take over control of some or all.
|-
|'''''Database support'''''
|Provides support for DB related to rails applications
|Provides support for DB related to rails applications
|It features serious production DB like RDBMS, Postgres, etc. and many Addons such as MongoDB, ClearDB, etc.
|Features free shared databases such as MongoDB, MySQL, Postgres but for other production DB’s need to use Addons
|Databases featured are MySQL, MongoDB and Postgres
| -
|Supports DB like Amazon SimpleDB, Amazon RDS, Amazon DynamoDB.
|-
|'''''Deployment strategy'''''
|Capistrano provides commands to be executed for automated deployment. It supports git.
|It is much easier to deploy using Vlad as compared to Capistrano.
|Deployment as easy as ‘git push’
|Deployment does not support git. It uses the af tool for deployment.
| -
|Since Cloud66 provides the platform in terms of Application Stack Management as a Service, it uses the infrastructure of AWS, Virtual Private Server, etc. for actual deployment. But the user doesn’t have to worry about configuration or monitoring of the servers. Hence provides easy deployment.
|Deployment options include Git, AWS management console, etc.
|-
|'''''Community Support availability'''''
| As it has been in use for a long time there is a huge community support available for Capistrano.
| -
|Heroku also provides a huge community support given the fact that there are a lot of Heroku users.
|Community is limited.
|RedHat being a reputed provider for open source solutions, the OpenShift community is gradually increasing and receiving support from a considerable community of users.
|Limited community support currently
|Has community forums and documentation.
|}


https://devcenter.heroku.com/articles/how-heroku-works#deploying-applications
= Conclusion =


https://github.com/heroku/heroku
Comparison and contrast between various deployment automated tools such as Capistrano, Heroku, Vlad, AppFog, OpenShift, Cloud66, AWS Beanstalk shows that each has its own pros and cons.
For instance, in a client based application where handing over the control of the application to a third party such as the deployment tool provider is impossible, AWS Beanstalk would be the obvious choice for the developer.
On the other hand, a novice Rails application developer might find all he needs in the starter plan of Heroku with the added bonus of a huge support community available to him for troubleshooting as he stumbles his way across the development of the application.
One may also choose the tool that provides the specific database support for your application. In case of large scale corporations where budgets are not that limited, the increasing costs with up-scaling of some tools would not be an obstacle.
Thus, various considerations about the application such as scalability requirement, security concerns, cost, availability of own resources such as servers etc., will help determine which tool is the most suitable for that application.


http://docs.seattlerb.org/vlad/index.html
= References =


<references/>
<references/>


= See Also =
= See Also =
* Rails Solutions: Ruby on Rails Made Easy by Justin Williams
* http://guides.beanstalkapp.com/deployments/best-practices.html
* http://www.urbancode.com/anthill3-help-3.7/html/SettingUpDeploymentProcess.html
* http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=UseFMSGateway_3.html
* http://pic.dhe.ibm.com/infocenter/tivihelp/v26r1/index.jsp?topic=%2Fcom.ibm.dtm.doc%2Fdeploysoftware%2Fc_deploysw_process.html

Latest revision as of 21:03, 24 September 2013

Code Deployment and Release Management with Rails

Code Deployment or Software Deployment and Release management with Ruby on Rails can be done using various tools such as Capistrano, Heroku, AppFog, OpenShift, AWS, Cloud 66, Vlad, etc. These automated tools are frameworks used to write and execute commands in parallel remote machines and thus ease the process of deployment and management of various applications.

Introduction

The Deploying process involves different stages like development, testing, release management and sign-off by project teams.

The following diagram illustrates the deployment process of an application.

<ref>http://technet.microsoft.com/en-us/library/cc465178.aspx</ref>


The deployment flow has three stages: development and testing, release management and stakeholders and project teams.

After the final release of the code in development and testing stage, the master plan is prepared for deployment of components and sites based on the sign-offs provided by the project teams, stakeholders and customers. Then, the stabilization of the deployment is calculated based on some metrics. Once the deployment is stabilized, it is reviewed and the process of deployment is complete. The final sign-off is given by the stakeholders.

Code Deployment

Code deployment is a procedure where the application is transferred onto a production server, so that it is made available for all the other users. It is the part of release management process which involves several activities. These activities are inter-dependent and need to be completed in a specific order for successful code deployment.

Code Deployment Activities

The various deployment activities include <ref>http://en.wikipedia.org/wiki/Software_deployment</ref>

  • Release : Gathering all system components in preparation for deployment
  • Install and activate : Installing the application components and getting them in the 'ready' state
  • Deactivate : Shutting down components that are out-dated or that may interfere with updating others
  • Adapt : Making changes to application to accommodate changes in environment
  • Update : Having a newer release installed in place of the old one
  • Built-in : There are components built-into some tools for complete/semi-automating updates
  • Version tracking : These systems help the user to know if newer versions of a software are available and if yes, help install them
  • Uninstall : Opposite of installation and involves complete removal of software and its dependencies from the environment
  • Retire : This involves making a software obsolete and is the end of software life cycle

The general guidelines for the deployment process remain the same but there are variations in the specific requirements with each software system.

Release Management

<ref>http://searchitchannel.techtarget.com/definition/release-management</ref> Release management is a software process which takes care of the development, testing, deployment and support stages of software releases. The start of release management happens in the development phase, where it requests for new features or changes in the existing application. When the request is accepted, a new release is planned and designed. This design is built and then enters the testing phase, where the release is tested until it is accepted. After the release is accepted as a candidate, it enters the deployment phase where it is implemented. Once deployed, the release is made available and sent to support phase for collection of bug reports. Once the support phase is done, the bugs and other issues lead to requests for changes and the cycle is then repeated.

Automating Code Deployment and Release Management

<ref>http://www.urbancode.com/html/solutions/deployment-automation.html</ref> Automation of a process is required when the manual process is more error prone. Also, for large real world applications, the manual process is very complex and time consuming. Incomplete documentation hampers a manual process further. Deployment also has to be done in many environments and involves varied steps to be followed in a specific order. Manual process needs repetition of same procedure to each and every environment which leads to many errors and the process becomes costly. In web applications each new release has to be deployed to and tested in development, testing and production environments.The number of software releases in web applications are more and hence the need to automate release management is also greater.

Automation of deployment delivers applications faster and with fewer errors. The defined software deployment process can be applied across all environments consistently every time. With various automated application deployment platforms now readily available, manual deployments have become a thing of the past.

Lets take a look at the various Deployment Automation tools available to Ruby on Rails applications. For the purposes of this article the process of manual deployment of a Ruby on Rails application is out of scope.

Deployment Automation tools

Some of the automated tools that are widely used for the process of deployment with Ruby on Rails are

  • Capistrano
  • Heroku
  • Vlad
  • AppFog
  • AWS Elastic Beanstalk
  • OpenShift
  • Cloud 66

Capistrano

Capistrano Logo

Capistrano is a Ruby tool which helps deploy an application to the server. Capistrano allows deploying to multiple machines at a time. It has many advanced options which help to deploy different kinds of applications. It also supports the scripting and execution of tasks.

Capistrano can be used to:

  • Deploy applications onto many machines simultaneously.
  • Automate the audits
  • Automate the common tasks of a team.

Capistrano can be made a part of a larger software by integrating it with another Ruby software.


<ref>http://www.capistranorb.com/documentation/getting-started/installation/</ref>   General Usage

The following commands will clone Capistrano, build the gem and install it locally.

$ gem install capistrano --pre --trust-policy HighSecurity

Or grab the bleeding edge head from:

$ git clone -b v3 https://github.com/capistrano/capistrano.git
$ cd capistrano
$ gem build *.gemspec
$ gem install *.gem

Signed Rubygems

As Capistrano is a signed gem, you should always be careful to use the --trust-policy flag when installing Gems, or since Bundler 1.3 you should use the same flag:

$ gem install capistrano --pre --trust-policy HighSecurity
$ bundle install --trust-policy HighSecurity

If you get a message that looks like:

ERROR:  While executing gem ... (Gem::Security::Exception)
unsigned gems are not allowed by the High Security policy

Then please complain to your Gem author, and have them start signing their Gems.

Usage in a Rails project

Add the following lines to the Gemfile to the :development group ideally.

group :development do
  gem 'capistrano-rails', '~> 0.0.7'
end

Heroku

Heroku Logo

Heroku is a cloud Platform as a Service (PaaS) which supports several programming languages. PaaS is a service model of Cloud computing wherein the provider offers resources like servers, software, database, etc. to the developer. Heroku helps manage environment-specific configurations separately from the source code, which provides greater security. Heroku is not just a deployment environment but it also impacts the development process. There are several principles of the development of application on Heroku.
• Applications and Codebases : Most of the development of the application is done on application’s codebase which is stored in a Version Control System (VCS)
• Dependencies : All the application dependencies such as plugins should be declared explicitly
• Configuration : Configuration of an application is all that varies in different deploys


Getting Started with Heroku

1. To get started with Heroku, go to https://id.heroku.com/signup/devcenter, signup for a Heroku account.

2. Then, download and install the Heroku toolbelt at https://toolbelt.heroku.com/ for your development system. You can also use Heroku command line instead of the online Heroku application.

3. After installing one of them, login using the email address and password used when creating the Heroku account:

<ref>https://github.com/heroku/heroku</ref>

$ heroku login
Enter your Heroku credentials.
Email: adam@example.com
Password:
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading SSH public key /Users/adam/.ssh/id_rsa.pub

Deploying Applications

Heroku uses git primarily to deploy the applications. When an application is created on Heroku, it associates the new git which is remote with the local git repository.

As a result, deploying code is just the familiar git push, but to the heroku remote instead:

<ref>https://devcenter.heroku.com/articles/how-heroku-works#deploying-applications</ref>

$ git push heroku master

Vlad

Vlad Logo

Vlad is another automated deployment tool which is simple to use. It integrates with rake and uses standard tools like SSH, rsync etc.

The main features of Vlad include

  • It uses very few dependencies which are simple.
  • It can execute commands on more than one server.
  • It syncs files to one or more servers.
  • It matches local and remote tasks.
  • It runs tests very fast.

Getting started with Vlad<ref>http://docs.seattlerb.org/vlad/doco/getting_started_txt.html</ref>

Create a deploy file, usually in “config/deploy.rb”:

set :application, "project"
set :domain, "example.com"
set :deploy_to, "/path/to/install"
set :repository, 'http://svn.example.com/project/branches/stable/'

This defaults to using ‘svn export’ from repository, and a single server for app, db, and www.

If you want a multi-config environment, change your config like so:

set :application, "project"
set :repository, 'http://svn.example.com/project/branches/stable/'

task :beta do
  set :domain,    "beta.example.com"
  set :deploy_to, "/path/to/install-beta"
end

task :dev do
  set :domain,    "dev.example.com"
  set :deploy_to, "/path/to/install-dev"
end

task :prod do
  set :domain,    "example.com"
  set :deploy_to, "/path/to/install"
end

Add the following to your Rakefile:

begin
  require 'vlad'
  Vlad.load
rescue LoadError
  # do nothing
end

Vlad.load has a lot of flexibility.

You can install vlad via:

% rake vlad:invoke COMMAND='sudo gem install vlad -y'

Initial Launch

Run rake vlad:setup vlad:update vlad:migrate vlad:start


<ref>http://docs.seattlerb.org/vlad/index.html</ref> Running Vlad

  • Using rake
task :shazam! do
  Rake::Task[:action1].invoke
  Rake::Task[:action2].invoke
end
  • Using SSH
Host example.com
    User fluffy_bunny

AppFog

AppFog Logo

AppFog is a PaaS built on Cloud Foundry which is another PaaS platform for deploying applications.

Features of AppFog are

  • It launches and runs fast.
  • It does not require configuring servers or installing frameworks.
  • It is compatible with code management systems like git, svn etc.

Installing AppFog<ref>http://blog.appfog.com/getting-started-with-appfogs-command-line/</ref>

‘af‘ command line tool is written in Ruby for installation.

Download and install Ruby Installer for Windows. The installer already includes RubyGems.

Be sure you use the Ruby-enabled command prompt window when you later install and use af. You access this command prompt from the Windows Start menu (All Programs > Ruby > Start Command Prompt with Ruby).

Finally, update RubyGems from the Ruby Command Prompt:

$ gem update --system
$ gem install af

Login with:

$ af login

Finally from within your source code directory:

$ af update hello-node

Getting Started with AppFog

target [url]                                       Reports current target or sets a new target
login [email] [--email, --password]                Login
info                                               System and account information

AWS Elastic Beanstalk

AWS Logo

Amazon Wen Services(AWS) offers Infrastructure as a Service (IaaS) and provides a complete set of resources for the development of a web application in minutes. AWS Elastic Beanstalk is a deployment tool of the AWS cloud.

With AWS Elastic Beanstalk, applications can be quickly deployed and managed in the AWS cloud without worrying about the infrastructure that runs those applications. AWS Elastic Beanstalk reduces management complexity without restricting choice or control. Once the application is uploaded AWS Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring. AWS Elastic Beanstalk uses highly reliable and scalable services.

AWS CLI

AWS Elastic Beanstalk uses a command line tool Eb, which helps you to deploy your application easily.

Getting Started with Eb<ref>http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-reference-get-started.html</ref>

To get started with the beanstalk CLI, you will need to download the command line tools at the AWS Sample Code & Libraries website.

Step 1: Initialize Your Git Repository

Eb is a command line interface that enables you to deploy applications quickly and more easily using Git. Eb is available as part of the Elastic Beanstalk command line tools package.

1. To install eb,install the following software onto your local computer:

2. Initialize your Git repository.

git init 

Step 2: Configuring AWS Elastic Beanstalk

1. From your directory where you created your local repository, type the following command.

eb init

2. When you are prompted for the access key ID, type your access key ID.

Enter your AWS Access Key ID (current value is "AKIAIOSFODNN7EXAMPLE"): 

3. When you are prompted for the secret access key, type your secret access key.

Enter your AWS Secret Access Key (current value is "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"): 

4. When you are prompted for the AWS Elastic Beanstalk application name, type the name of the application.

Enter an AWS Elastic Beanstalk application name (auto-generated value is "windows"): 

Note: If you have a space in your application name, make sure you do not use quotes.

5. When you are prompted for the AWS Elastic Beanstalk environment name, type the name of the environment. AWS Elastic Beanstalk automatically creates an environment name based on your application name. If you want to accept the default, press Enter.

Enter an AWS Elastic Beanstalk environment name (current value is "HelloWorld-env"): 

6. When you are prompted to create an Amazon RDS DB instance, type y or n. For this example, we'll type y.

Create an RDS DB Instance? [y/n]:

7. When you are prompted to enter your RDS user master password, type your password containing from 8 to 16 printable ASCII characters (excluding /, \, and @).

Enter an RDS DB master password: 
Retype password to confirm: 

You can now get started with the AWS Elastic Beanstalk.

OpenShift

OpenShift Logo

Another free and open source PaaS for deploying applications is OpenShift created by [RedHat].

Considerations

  • Databases

To use the application outside the OpenShift environment one needs to change the variables as the application is configured to use database in production mode in OpenShift.

  • Assets

The assets are precompiled everytime application is pushed to OpenShift.

  • Security

Security related variables are to be unique across the application.

<ref>https://github.com/openshift/rails-example</ref> Installation

1. Create an account at http://openshift.redhat.com/

2. Create a rails application

rhc app create -a railsapp -t ruby-1.9

3. Add mysql support to your application

rhc cartridge add -a railsapp -c mysql-5.1

4. Add this upstream Rails quickstart repository

cd railsapp
git remote add upstream -m master git://github.com/openshift/rails-example.git
git pull -s recursive -X theirs upstream master

5. Push your new code

git push

Cloud 66

Cloud66 Logo

Cloud 66 combines the convenience of Platform-as-a-Service (PaaS) and the flexibility and control of Infrastructure-as-a-Service (IaaS). This platform allows easy deployment of application, so there is no overhead of configuring or monitoring the servers.

Cloud 66 Command line Toolbelt

Toolbelt is an open source released to deploy the application.

<ref>http://blog.cloud66.com/</ref>

Getting Started with Cloud 66

1. Go to the sign up page and create a Cloud 66 account.

2. Go to Cloud 66 Dashboard and build your first stack.

Installation

Installation of toolbelt uses the following command

Gem install c66

This automatically searches the newest version and installs it.

Comparison between Capistrano/Vlad/Heroku/AppFog/OpenShift/Cloud66/AWS Beanstalk

With so many automated tools available for Code Deployment and Release Management, the decision on which to use for a particular Ruby on rails application depends on various parameters to be considered. Some comparative features of the different tools are as follows :

Criteria for Comparision Capistrano Vlad Heroku AppFog OpenShift Cloud66 AWS Beanstalk
Getting started with the tool It is a framework that allows one to execute commands on a remote server using tools like ssh. Vlad deployment is similar to Capistrano, but less complex. Heroku’s offers a plan with first dyno free i.e. 512 MB that can be paired with Postgres starter DB to start an application with 0 initial cost AppFog’s initial plan offers 2GB of RAM free which is enough for small to medium traffic applications. By managing options provided for DB, queue server, application server, etc all part of the intial package, this is an excellent option to try out an application OpenShift is an open source platform and its free plan for starters has 3 gears for free wherein each gear consists of some RAM and disk space. Free plan provides one server for deployment. Provides an initial free tier. Without free tier no additional cost for Beanstalk. One only needs to pay for the AWS resources used.
Scaling Memory Memory increase would require additional servers/unused space in existing ones. Memory increase depends on additional servers available/unused space in existing ones. Memory increased in terms of dyno each of size 512 MB. Can configure any size for memory allocation - - Can automatically up/down scale the application by adjusting the default auto scaling settings.
Scaling – Cost and Ease While this provides greater flexibility as user is in control of the servers, it also causes additional overhead in terms of user needing to work both on Rails application and web server deployment. It can be integrated with Rake without any hindrances. Can dynamically scale up and down an application and pay as per hourly usages. Each additional dyno costs $35/mo Scaling takes up some time and need to pay for a month at the minimum. Scaling up to 4GB increases cost to $100/mo - Scaling using Cloud66 is relatively easy and hassle free. Scaling is fast and easy.
Special features For sensitive applications where handing over the control to a third party for deployment is not feasible, Capistrano is the way to go. It also provides support for tools like rsync and ssh. Lacks support for cross region deployment i.e. can’t select location of server where application gets deployed Supports cross region deployment i.e. if users of application primarily in Asia, can choose a server in Asia to deploy application, thus making the site faster. - - Provides complete flexibility and control of the resources to the user including the chance to take over control of some or all.
Database support Provides support for DB related to rails applications Provides support for DB related to rails applications It features serious production DB like RDBMS, Postgres, etc. and many Addons such as MongoDB, ClearDB, etc. Features free shared databases such as MongoDB, MySQL, Postgres but for other production DB’s need to use Addons Databases featured are MySQL, MongoDB and Postgres - Supports DB like Amazon SimpleDB, Amazon RDS, Amazon DynamoDB.
Deployment strategy Capistrano provides commands to be executed for automated deployment. It supports git. It is much easier to deploy using Vlad as compared to Capistrano. Deployment as easy as ‘git push’ Deployment does not support git. It uses the af tool for deployment. - Since Cloud66 provides the platform in terms of Application Stack Management as a Service, it uses the infrastructure of AWS, Virtual Private Server, etc. for actual deployment. But the user doesn’t have to worry about configuration or monitoring of the servers. Hence provides easy deployment. Deployment options include Git, AWS management console, etc.
Community Support availability As it has been in use for a long time there is a huge community support available for Capistrano. - Heroku also provides a huge community support given the fact that there are a lot of Heroku users. Community is limited. RedHat being a reputed provider for open source solutions, the OpenShift community is gradually increasing and receiving support from a considerable community of users. Limited community support currently Has community forums and documentation.

Conclusion

Comparison and contrast between various deployment automated tools such as Capistrano, Heroku, Vlad, AppFog, OpenShift, Cloud66, AWS Beanstalk shows that each has its own pros and cons. For instance, in a client based application where handing over the control of the application to a third party such as the deployment tool provider is impossible, AWS Beanstalk would be the obvious choice for the developer. On the other hand, a novice Rails application developer might find all he needs in the starter plan of Heroku with the added bonus of a huge support community available to him for troubleshooting as he stumbles his way across the development of the application. One may also choose the tool that provides the specific database support for your application. In case of large scale corporations where budgets are not that limited, the increasing costs with up-scaling of some tools would not be an obstacle. Thus, various considerations about the application such as scalability requirement, security concerns, cost, availability of own resources such as servers etc., will help determine which tool is the most suitable for that application.

References

<references/>

See Also