Easy Deployment of Rack Applications with Juju

by Pavel PachkovskijMarch 1, 2013
Providing step-by-step instructions, this blog post explores how to deploy Rack applications with the Juju orchestration tool.

What is Juju?

Juju is a service orchestration management tool developed by Canonical. With Juju, it is easy to build entire environments on public clouds, such as Amazon Web Services and HP Cloud, as well as private clouds built on OpenStack or raw bare metal via MAAS.

Juju uses Charms—scripts that can be written in any language to deploy and configure services. There are over 100 services ready to deploy.

With Rack Charm, you can deploy your applications on Amazon EC2 in just a few minutes. Let me provide you some examples. All the examples are tested for Ubuntu 12.04 Precise Pangolin.

 

Getting started

Install Juju.

sudo add-apt-repository ppa:juju/pkgs
sudo apt-get update && sudo apt-get install juju

Run the command-line utility with no arguments to create a sample environment.

juju bootstrap

Configure your ~/.juju/environments.yaml environment. See how to run services on your local machine via Linux containers in this documentation. Below is the Amazon EC2 example.

default: sample
  environments:
    sample:
      type: ec2
      access-key: YOUR-ACCESS-KEY-GOES-HERE
      secret-key: YOUR-SECRET-KEY-GOES-HERE
      control-bucket: juju-faefb490d69a41f0a3616a4808e0766b
      admin-secret: 81a1e7429e6847c4941fda7591246594
      default-series: precise
      juju-origin: ppa
      ssl-hostname-verification: true

Bootstrap the environment.

juju bootstrap

 

Sinatra example with the html2haml app

Deploy a web server.

juju deploy nginx-passenger

Create a configuration file for Rack Charm. Let’s call it html2haml.yml.

html2haml:
  repo_url: https://github.com/twilson63/html2haml.git
  app_name: html2haml

Deploy Rack Charm with the config you have created in the previous step.

juju deploy rack html2haml --config html2haml.yml

Relate the config to the web server.

juju add-relation html2haml nginx-passenger

Open the stack up to the outside world.

juju expose nginx-passenger

Find the nginx-passenger instance’s public URL.

juju status

 

The Ruby-on-Rails v3.0 example

In Ruby on Rails, the process resembles the Sinatra deployment, but additionally, the PostgreSQL database is used.

Create the sample_rails.yml config file.

sample_rails:
  repo_url: https://github.com/pavelpachkovskij/sample-rails.git
  app_name: sample_rails

Deploy the application and the web server.

juju deploy rack sample_rails --config sample_rails.yml
juju deploy nginx-passenger
juju add-relation sample_rails nginx-passenger

Deploy PostgreSQL and relate it to the application.

juju deploy postgresql
juju add-relation postgresql:db sample_rails

Expose nginx-passenger and find its public URL.

juju expose nginx-passenger
juju status

For more, check out the Juju documentation and the Juju GUI documentation. Juju GUI is a web interface you can deploy right into your environment. It lets you model and design the entire stack via a web browser, including integration with the Juju Charm Store.

 

Further reading

 

About the author

Pavel Pachkovskij has experience in front- and back-end development of web applications. He is proficient in Ruby, Ruby on Rails, JavaScript, CSS, etc. Pavel also worked with relational databases, such as MySQL, MariaDB, PostgreSQL, as well as NoSQL solutions, such as MongoDB and Redis. Find him on GitHub.


The post was written by Pavel Pachkovskij and edited by Alex Khizhniak.