Afternoon all,

As your probably aware I’ve recently been enamoured by the Ubuntu keynote by Mark Shuttleworth around Juju and MAAS, and – in true engineering / science methodology, i wanted to get my hands on it and have a play around (of course!).

However, as I dont have a data centre at my disposal or a ton of HP Moonshot servers, MAAS is out of the question so AWS will have to suffice…

Installation

First and foremost, i decided to start by running the latest Ubuntu 13.04 version – which touts Juju, Landscape, Openstack etc capabilities. I wont bore you with installation details (as i didnt do it, i just simply span up a new instance in EC2!).

Once the instance was up, i got SSH access to it and ran the below commands as per the documentation here (link):

sudo add-apt-repository ppa:juju/devel
sudo apt-get update && sudo apt-get install juju-core
sudo apt-get install juju-core
ssh-keygen -t rsa -b 2048
juju generate-config -w

Next we have to edit our configuration file to specify what we are deploying Juju onto, so we need to edit the file ~/.juju/environments.yaml as below:

## https://juju.ubuntu.com/get-started/amazon/
 amazon:
 type: ec2
 admin-secret: valuehere
 # globally unique S3 bucket name
 control-bucket: valuehere
 # override if your workstation is running a different series to which you are deploying
 # default-series: precise
 # region defaults to us-east-1, override if required
 region: eu-west-1
 # Usually set via the env variable AWS_ACCESS_KEY_ID, but can be specified here
 access-key: valuehere
 # Usually set via the env variable AWS_SECRET_ACCESS_KEY, but can be specified here
 secret-key: valuehere

Dont worry if that seems like a lot to remember, its all there already – you just need to edit it and add your own values for access-key, secret-key and a few others if you desire.

Once you’ve modified the files, we need to:

juju bootstrap
juju deploy juju-gui
juju expose juju-gui
juju status

This will bootstrap juju from our modified config file, deploy the GUI element of it, and then expose it. Finally, we will output our juju status showing us our public IP (so we can access it!):

ubuntu@inforemoved:~$ juju status
machines:
 "0":
 agent-state: started
 agent-version: 1.11.0
 dns-name: ec2-inforemoved.eu-west-1.compute.amazonaws.com
 instance-id: i-7xxxxxxz
 series: precise
 "1":
 agent-state: started
 agent-version: 1.11.0
 dns-name: ec2-inforemoved1.eu-west-1.compute.amazonaws.com
 instance-id: i-7xxxxxxx
 series: precise
services:
 juju-gui:
 charm: cs:precise/juju-gui-61
 exposed: true
 units:
 juju-gui/0:
 agent-state: started
 agent-version: 1.11.0
 machine: "1"
 <strong>public-address: ec2-inforemoved2.eu-west-1.compute.amazonaws.com</strong>

 

Now that Juju is up and running, we can access it using the public-address value as above using a standard web browser (if you are using AWS like me, remember to modify the security group first to allow HTTP through).

Logging in to the GUI

Firstly, navigate to the address listed above in a browser and you will see a screen similar to:

juju 1

The password for your juju is the “admin-secret” as set or modified in in the file ~/.juju/environments.yaml – so for our example, we use the “admin-secret” value set against the EC2 section of the configuration.

Once logged in, we will see a screen as below:

juju 2

 

This is our “juju dashboard” – congratulations, you now have your own Juju system!

Deploying new software

As outlined in the official Juju blurb here (link) Juju is charm based (Juju being the Afrikaans (?) term for magic i believe) where the charms are used as part of a potion or some nonsense. Either way, the concept is that these charms are using by Juju to create a bigger picture (a potion, ooo) – where the charms are software such as MySQL, Hadoop, WordPress, etc and the potion is well.. your application.

The beauty of this object approach (charm offensive, oof) is that you can add in community created charms which means that the growth rate for the the Juju charm community should be very steep with users adding more and more charms.

To deploy a new charm or app, we can either use the GUI above (drag and drop), or we can use the command line (much more fun) as below.

In our example, we are going to deploy wordpress and MySQL and link them together, as outlined in the official documentation. To do this, we should first deploy a wordpress and mysql charm into our environment, and link them together as below:

juju deploy wordpress
juju deploy mysql
juju add-relation wordpress mysql

This will take a few minutes, so go get a brew as we say in the UK.

Once your deployment is finished, we will be able to see the new application via CLI using “juju status”:

...
mysql:
 charm: cs:precise/mysql-24
 exposed: false
 relations:
 cluster:
 - mysql
 db:
 - wordpress
 units:
 mysql/0:
 agent-state: started
 agent-version: 1.11.0
 machine: "5"
 public-address: addressremoved1.eu-west-1.compute.amazonaws.com
 wordpress:
 charm: cs:precise/wordpress-15
 exposed: false
 relations:
 db:
 - mysql
 loadbalancer:
 - wordpress
 units:
 wordpress/0:
 agent-state: started
 agent-version: 1.11.0
 machine: "4"
 public-address: addressremoved.eu-west-1.compute.amazonaws.com
..

…or via the snazzy GUI as below:

juju 3

 

Finally, we need to expose the new charm using the command “juju expose wordpress” and voila, the deployment is complete (Literally, as easy as that…).

We then take the public IP of wordpress which we get out of “juju status”, slap it in a web browser, and voila:

juju 4

 

Juju and scalability

You can even SCALE using Juju using commands such as:

juju add-unit wordpress
juju add-unit -n5 wordpress

To add either 1, or 5 (-n5) more units of wordpress to help with workload if the one wordpress server is struggling.

Or, we can also add memcached using similar methodology as below:

juju deploy memcached
juju add-relation wordpress memcached

Simply deploy, and add the relationship. Easy!

Closing Thoughts

I honestly cannot say enough about how impressed I am with Juju and the ease of deployment it allows. Providing you have enough Charms, or charms for the right software required, you could feasibly deploy your entire software estate via this one tool.

Definitely one to watch, along with MAAS from Ubuntu – very impressive work gentlemen..