Showing posts with label juju. Show all posts
Showing posts with label juju. Show all posts

16 January 2015

Write Juju charm

In the last tutorial(tutorial1) we discuss what is juju and what are the capabilities in juju. In juju all the concepts based on juju charms.Basically individual component is called juju charm. Developers can build their charms and publish in to juju charm store(https://demo.jujucharms.com/).This image shows how to add mysql charm and wordpress charm and add relations between them.



Why use juju ??

Juju is a framework which support deploy applications to any cloud or Ubuntu based environment simple and more flexibility.

What is juju charm ??

Charm is individual component which used to manage service. If  we get simple service  "mysql database" or "wordpress".If you need to deploy these service in to your cloud environment you need to just drag and drop these charms and connect them through GUI.

Write Hello world charm.

When you write charm you may use python or bash script as programming languages.In here i will create "Helloworld" charm and then deploy in LXC container. 

First need to install charm tools.

sudo apt-get install charm-tools
Then create Helloworld charm

charm create hello_world

Then it look like this one.It contains hooks folder and config.yaml and metadata.yaml
Then inside hooks folder   there are several scripts files.These are "install" , "config-changed","start","stop","upgrade-charm" and other relation changed and relation joined scripts.

Charm life cycle 

In this flow diagram show how scripts inside hooks folder runs.


First it runs "install" hook which used to install all the dependencies to the charm.For example if your charm need java or python need to install before start application in your environment you have to mention these dependencies in install hook.

Then It runs "config-changed" hook.It is responsible for act  when changing configuration in charms.And then "start" hook runs.It is responsible for start the application.It may be server or service.

And there are other three hooks which are related to changed or add relations to charms.As example if mysql charm need to connect to wordpress charm we have to add relation between mysql and wordpress.

And Last Step it runs "stop" hook.Which is responsible for shutdown all services provided in charm.

22 August 2014

Install juju in local lxc contanier

Install JUJU in ubuntu

In this thread i have described how to install juju in ubuntu 14.04.First You have to install juju in to your machine.
   
   sudo apt-add-repository ppa:juju/stable
   sudo apt-get update
And then install juju-core in to your machine.It might takes more times based on your internet connection.
sudo apt-get install juju-local
Then for the configuration 
juju generate-config
juju switch local
Then You need to bootstrap the local environment.So Then enter this command
juju bootstrap --show-log
This might be take more than 20 minutes it is based on your internet connection.After installing juju you can check the status of the juju environment.
juju status
Then for the Testing you can install juju GUI.This will help you to understand what charm is running and what are the relationships using graphical view.
juju deploy juju-gui
juju expose juju-gui

How to create juju charm

First you have to install juju and then you have install charm tools for juju.
sudo add-apt-repository ppa:juju/stable
sudo apt-get update;
sudo apt-get install charm-tools;