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

From Expertiza_Wiki
Jump to navigation Jump to search
Line 11: Line 11:
The following diagram illustrates the deployment process of an application.
The following diagram illustrates the deployment process of an application.


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





Revision as of 03:35, 18 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. 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>


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 have transitions between them to help the code deployment complete its process.

Code Deployment Activities

The various deployment activities include

  • Release
  • Install and activate
  • Deactivate
  • Adapt
  • Update
  • Built-in
  • Version tracking
  • Uninstall and retire

The general guidelines for the deployment process remains same with variations in the specific requirements with each software system.

Release Management

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.

Why Automate Deployment

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.

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.

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
  • OpenShift
  • Cloud 66

Capistrano

Capistrano is a Ruby tool which helps you deploy your 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.

Installing Capistrano

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 is a cloud Platform as a Service (PaaS) which supports several programming languages. It helps you manage environment-specific configurations separately from the source code, which provides greater security. Heroku is not just a deployment environment but it also impacts its development process. There are several principles of the development of application on Heroku. • Applications and Codebases o Most of the development of the application is done on application’s codebase which is stored in a Version Control System (VCS) • Dependencies o All the application dependencies such as plugins should be declared explicitly • Configuration o Configuration of an application is all that varies in different deploys

Heroku CLI

Heroku CLI is managing Heroku applications over command line.

Once Heroku CLI is 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:

$ 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:

$ git push heroku master

Vlad

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 servers.
  • It syncs files to one or more servers.
  • It matches local and remote tasks.
  • It runs tests very fast

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 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.

Installation

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

Getting Started

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

AWS

AWS provides a complete set of services for the development of a web application within minutes. With AWS Elastic Beanstalk, you can quickly deploy and manage applications in the AWS cloud without worrying about the infrastructure that runs those applications. AWS Elastic Beanstalk reduces management complexity without restricting choice or control. You simply upload your application, and 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.

Run the sample using a command line interface. For example:

eb status

OpenShift

Another free and open source PaaS for deploying applications is OpenShift.

Considerations

  • Databases

To use your application outside the OpenShift environment you need to change the variables as the application is configured to use database in production mode in OpenShift.

  • Assets

The assets are precompiled everytime you push to OpenShift.

  • Security

We should ensure that the security related variables are unique across the application.

Installation

1. Create an account at http://openshift.redhat.com/ 2. Create a rails application

3.

rhc app create -a railsapp -t ruby-1.9

4. Add mysql support to your application

5.

rhc cartridge add -a railsapp -c mysql-5.1

6. Add this upstream Rails quickstart repository

7.

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

10. Push your new code

git push

Cloud 66

Cloud 66 uses Application Stack Management as a Service. This platform allows easy deployment of application, so you don’t have the overhead of configuring or monitoring your servers.

Cloud 66 Command line Toolbelt

Toolbelt is an open source released to deploy the application.

Installation

Installation of toolbelt uses the following command

Gem install c66

This automatically searches the newest version and installs it.

Comparison between Capistrano/Heroku/Vlad

Criteria Capistrano Heroku Vlad
"Take some more [[tea]]," the March Hare said to Alice, very earnestly.

"I've had '''nothing''' yet," Alice replied in an offended tone, "so I can't take more."

"You mean you can't take ''less''?" said the Hatter. "It's very easy to take ''more'' than nothing."
<p>"Take some more <a title="Tea" href="/wiki/Tea">tea</a>," the March Hare said to Alice, very earnestly.</p>

<p>"I've had <strong>nothing</strong> yet," Alice replied in an offended tone, "so I can't take more."</p>

<p>"You mean you can't take <em>less</em>?" said the Hatter. "It's very easy to take <em>more</em> than nothing."</p>

"Take some more tea," the March Hare said to Alice, very earnestly.

"I've had nothing yet," Alice replied in an offended tone, "so I can't take more."

"You mean you can't take less?" said the Hatter. "It's very easy to take more than nothing."

Conclusion

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

References

http://technet.microsoft.com

http://searchitchannel.techtarget.com/definition/release-management

http://www.capistranorb.com/documentation/getting-started/installation/

http://www.urbancode.com/html/solutions/deployment-automation.html

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

https://github.com/heroku/heroku

http://docs.seattlerb.org/vlad/index.html https://github.com/openshift/rails-example http://blog.cloud66.com/ http://www.itcentralstation.com/node/28970

<references/>

See Also