Getting Started With Juju Locally

Juju is a great tool that allows us to deploy many services in a local or cloud environment. Services are deployed into virtual containers and can be removed and re-deployed at any time. It is perfect for creating sandbox and test environments for specific kind of services that you develop for.

In this post I will explain how easy it is to get started with Juju in a local environment.

Installation

To start we will need to add the necessary repository from where we will retrieve the Juju packages:

sudo add-apt-repository ppa:juju/stable
sudo apt-get update

Next we will download and install the Juju core package and the package for local deployment:

sudo apt-get install juju-core
sudo apt-get install juju-local

Setting Up the Local Environment

Before we set up the local environment, let's first generate a configuration file. This file will contain the configuration for many kinds of environments (OpenStack, AWS, MaaS, etc.), including a local environment configuration. We will generate the file and then switch to the local environment:

juju generate-config
juju switch local

Once we have switched to the local environment, we can simply bootstrap the environment with the following command:

juju bootstrap

After the process is complete, we are now ready to start using Juju.

Deploying Services

We can now start deploying our services. For example you can deploy the typical Wordpress service:

juju deploy wordpress

However, we want to focus on deploying our custom services from our custom local charms. Let's create a directory for our local charms:

mkdir -p /home/$USER/charms/trusty/

We will place the Juju charm directories inside that directory. For example, I can clone my Zenoss Core 4 charm into that directory and then Zenoss Core:

cd $/home/$USER/charms/trusty/
git clone https://github.com/aalvrz/zenoss-charm.git

juju deploy --repository=/home/$USER/charms/ local:trusty/zenoss

Juju will fetch for the charm under that directory and begin deploying the service. I can then monitor the status of the deployment using:

watch -n 0.5 juju status zenoss --format tabular

As well as tracking the logs generated by Juju:

juju debug-log | grep zenoss

Enabling IP Tables for Local Services

Juju will create a container for a deployed service. When the deployment is finished, we can access that service using the address shown in the public-address field (use juju status). However, when navigating to that address using a web browser, it is very possible that we will not be able to access the service due to IP tables.

We can add a rule to enable the service:

iptables -t nat -A PREROUTING -i eth0 -p tcp -d $FORWARD_IP --dport 80 -j DNAT --to-destination $DEST_IP:8080

Where:

Note that I appended the port used by Zenoss (8080) to the $DEST_IP field.

juju devops linux zenoss iptables

Comments

comments powered by Disqus