Over a million developers have joined DZone.
Platinum Partner

Deploying multiple services on one cloud server instantly…

· Cloud Zone

The Cloud Zone is brought to you in partnership with Mendix. Better understand the aPaaS landscape and how the right platform can accelerate your software delivery cadence and capacity with the Gartner 2015 Magic Quadrant for Enterprise Application Platform as a Service.

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

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
if [ ! -f ~/.juju/environments.yaml ]; then
echo "Generating environments.yaml."
juju generate-config -w
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

The Cloud Zone is brought to you in partnership with Mendix. Discover how Mendix for Mobile App Deveopment makes it incredibly fast and easy for any developer to build engaging multi-channel apps.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}