Over a million developers have joined DZone.

Deploying Multiple Services on One Cloud Server Instantly

· DevOps Zone

Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure, brought to you in partnership with Sauce Labs

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

Download “The DevOps Journey - From Waterfall to Continuous Delivery” to learn learn about the importance of integrating automated testing into the DevOps workflow, brought to you in partnership with Sauce Labs.

Topics:

Published at DZone with permission of Maarten Ectors, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}