Cloud Zone is brought to you in partnership with:

Disruptive Innovator and Senior Executive with a passion transforming industries by applying cutting edge technologies (Cloud, Big Data, M2M, Distributed Machine Learning, Open Source Hardware, etc.) and business innovations (Freemium, Gamification, Social, Long Tail, Pay per Use, SaaS Subscriptions, Design Thinking, Blue Ocean Strategy, Lean Startup, etc.) to generate new revenues Maarten is a DZone MVB and is not an employee of DZone and has posted 41 posts at DZone. You can read more from them at their website. View Full User Profile

Deploying multiple services on one cloud server instantly…

07.23.2013
| 1608 views |
  • submit to reddit

There was a new release of Juju this week, 1.11.3, that brought a “small feature” with a big impact on your AWS bill. You are now able to deploy multiple services on one cloud server instantly. Before Juju started a new server per service which resulted in a potentially high AWS bill.

If you want to use the new feature you need to work with the development version of Juju Core. To install Juju on AWS just copy the below code into a file, e.g. installjuju.sh, make it executable: chmod u+x installjuju.sh and execute it: ./installjuju.sh

#!/bin/bash
echo "Installing Juju. Asks for your password."
sudo add-apt-repository ppa:juju/devel -y
sudo apt-get update -y
sudo apt-get install juju-core -y
if [ ! -f ~/.ssh/id_rsa ]; then
echo "Generating SSH Keys."
ssh-keygen -t rsa -b 2048
fi
if [ ! -f ~/.juju/environments.yaml ]; then
echo "Generating environments.yaml."
juju generate-config -w
fi
echo "Your AWS Access Key, followed by [Enter]:"
read awsaccesskey
echo "Your AWS Secret Key, followed by [Enter]:"
read awssecretkey
sed -i -e "s/# access-key: /access-key: $awsaccesskey/" ~/.juju/environments.yaml
sed -i -e "s/# secret-key: /secret-key: $awssecretkey/" ~/.juju/environments.yaml
echo "Bootstrapping Juju."
juju bootstrap

Afterwards you can start deploying services. If you want them to run on the same server you need to know the number of the server. Juju status will tell you this:

juju status

The bootstrap server is 0. New machines will be starting with 1 and go up. So if we want to install wordpress then we need to do the following:

juju deploy mysql --to 0 # deploy mysql to machine 0
juju deploy wordpress --to 0 # deploy wordpress to machine 0
juju add-relation mysql wordpress # create wordpress tables
juju expose wordpress # make wordpress accessible.
juju status # get the IP/URL of wordpress

Now you can log into WordPress. Your URL should look something like this:
http://ec2-<some numbers>-.compute-1.amazonaws.com

When you are done:

juju destroy-environment




Published at DZone with permission of Maarten Ectors, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)