CHARMS

  • DEPLOYING OMG! UBUNTU! TO THE CLOUD WITH JUJU!

    AUTHOR: // CATEGORY: charms, Cloud, juju, Planet, Ubuntu

    6 Comments

    For the last month we’ve been working on getting the perfect charm setup for the OMG! Ubuntu! website. Today we deploy the final version of the charm just in time for the 12.04 release. It’s been a long road, but now that we’ve wrapped this up it’s time to take all the knowledge we’ve gained in the past month about scaling WordPress (from caching to session management) and place it in the stock WordPress charm, making it anything but stock. What has made this otherwise grueling experience easy and enjoyable is Juju. No longer do we have to toil with different environments, upgrade paths, or even major documentation. Since we’ve encapsulated all of our tweaks in the charm, deploying and performing large upgrades is relatively streamlined.

    To demonstrate how easy it is to get OMG! Ubuntu! running I’ve recorded the latest deployment on shelr.tv where I created a new environment, bootstrapped it, deployed, then re-pointed the IP address in AWS. What you see in the terminal cast is what’s running OMG! Ubuntu! right now. Compared to traditional deployments, the process is effortless. This terminal cast outlines the deployment of OMG! Ubuntu! from nothing to a running blog. Since it takes about 10 minutes to do the first deploy (imagine having to pull down about 5-10 GB worth of assets, database dumps, etc then import those in to MySQL), I decided to cut there and create this additional short video on how to scale out the deployment.

    It’s a fantastic thing. Sure we’ve been rushing around trying all these different methods, but at the end of the day that time was well invested. Now deployments for OMG! Ubuntu! (and WordPress) are easy. In minutes you have a battle ready, tried and true blogging software deployed to the cloud.

  • PHPMYADMIN CHARM READY!

    AUTHOR: // CATEGORY: charms, Cloud, juju, Ubuntu

    1 Comment

    As a follow up to my previous post about the Minecraft Charm, here is my next completed charm: phpMyAdmin! Unlike my last charm’s post, I’m going to keep this one sweet and to the point. For a review on how to setup your local charm directory and environment see the aforementioned post, or checkout the Documentation. In summary you’ll need to fetch this charm, bootstrap a deployment environment, deploy MySQL charm and phpMyAdmin charm, create a relationship between the two, and expose the service. All of that is demonstrated in the video with a transcript of the commands available below.

    mkdir -p ~/Projects/charms/oneiric
    charm get mysql ~/Projects/charms/oneiric/mysql
    charm get phpmyadmin ~/Projects/charms/oneiric/phpmyadmin
    juju bootstrap
    juju deploy --repository ~/Projects/charms local:mysql
    juju deploy --repository ~/Projects/charms local:phpmyadmin
    juju add-relation phpmyadmin mysql
    juju set phpmyadmin password="password" # Replace password with your actually password
    juju expose phpmyadmin

    For switching to use the latest upstream, execute the following:

    juju set phpmyadmin use_upstream=true

    Setting this value to false will revert the installation back to the one provided via the Ubuntu Archives. There are a few other features to this charm which are documented in the readme file.

  • DEPLOYING THE MINECRAFT CHARM!

    AUTHOR: // CATEGORY: charms, Cloud, juju, Ubuntu

    3 Comments

    Updated 2013/04/17: Reflect Charm Store, updated links, removed several out of date paragraphs.

     

    For the past three weeks I’ve been working with Charms, which are part of the Juju project. I love charms, I even went so far as to join the Charmers group on Launchpad. During the Ubuntu Developer Summit I was lucky enough to sit down with a few of the Juju hackers and get a first hand look at developing an deploying charms. There are lots of videos showing how quick and easy it is to deploy Hadoop, WordPress, and MySQL to the cloud but those demos always just kind of sailed over my head, because I didn’t really care about that kind of infrastructure.

    Juju!

    So, you want to run a Minecraft server in the cloud. First you’ll need to grab juju – if you’re running the latest and greatest Ubuntu release then installation is a pretty straight forward process execute the following lines to add the Juju PPA and install Juju along with the additional charm tools.

    sudo add-apt-repository ppa:juju/pkgs
    sudo apt-get update && sudo apt-get install juju charm-tools

    Finally, we need to setup an environment for which to deploy these charms to! Run juju once to have Juju create it’s environments file, which is placed in ~/.juju/environments.yaml Since I use Amazon’s Web Services (AWS) EC2, all I had to do was add two extra keys one for access-key and the other secret-key. These are the access and secret keys (respectively) from your Amazon Web Service account. All of this can be found in the documentation

    Now you’re ready for some charming!

    There are a whole bunch of directions you can go in now. You can pull down all the charms in the Charm Browser, you can checkout the list of charms that are still in development/awaiting approval, or you can just deploy the totally awesome Minecraft charm. Lets do that! You’ll need to setup the cloud for deployment. This is done via bootstrapping, which will create an instance on the cloud that acts as the gatekeeper and manager for all services and charms you deploy with Juju to the cloud.

    juju bootstrap

    Bootstrapping can take up to five minutes to complete and it runs in the background. So even though the command completed doesn’t always mean the environment is ready! You can check on the Juju environment anytime by issuing the juju status command. Output, when bootstrapping is completed, will look like this

    2011-11-16 13:18:27,464 INFO Connecting to environment.
    machines:
      0: {dns-name: ec2-50-19-58-136.compute-1.amazonaws.com, instance-id: i-45bdd926}
    2011-11-16 13:18:28,408 INFO 'status' command finished successfully

    So we’ve got one machine (our bootstrap!) and it’s all ready to rock and roll. So, lets deploy!

    juju deploy minecraft

    When that command completes, it’ll send a request to the bootstrap machine to spin up a minecraft service (just so you know, charms that are deployed are called services). It’s almost ready to rock and roll! Check on the machine periodically using the juju status command, eventually you’ll end up with the following:

    2011-11-16 13:28:14,584 INFO Connecting to environment.
    machines:
      0: {dns-name: ec2-50-19-58-136.compute-1.amazonaws.com, instance-id: i-45bdd926}
      1: {dns-name: ec2-50-17-53-192.compute-1.amazonaws.com, instance-id: i-fdb8dc9e}
    services:
      minecraft:
        charm: local:oneiric/minecraft-1
        exposed: false
        relations: {}
        units:
          minecraft/0:
            machine: 1
            open-ports:
            public-address: ec2-50-17-53-192.compute-1.amazonaws.com
            relations: {}
            state: started
    2011-11-16 13:28:15,711 INFO 'status' command finished successfully

    As is shown, there are two machines now, bootstrap and the newly created minecraft machine. We have one service running, minecraft, and a bunch of other information, most importantly the state and public-address. As is shown, the machine is started! So everything went A-OK! All that needs to happen now: Expose the server to the outside world. Exposing simply opens the appropriate ports for a service, if required. In this case we want our server to be available to the rest of the world so they can play! You can do this by running

    juju expose minecraft

    Running juju status one more time will show that the Minecraft service is now exposed and ready to rock and roll

    2011-11-16 13:32:18,630 INFO Connecting to environment.
    machines:
      0: {dns-name: ec2-50-19-58-136.compute-1.amazonaws.com, instance-id: i-45bdd926}
      1: {dns-name: ec2-50-17-53-192.compute-1.amazonaws.com, instance-id: i-fdb8dc9e}
    services:
      minecraft:
        charm: local:oneiric/minecraft-1
        exposed: true
        relations: {}
        units:
          minecraft/0:
            machine: 1
            open-ports: [25565/tcp]
            public-address: ec2-50-17-53-192.compute-1.amazonaws.com
            relations: {}
            state: started
    2011-11-16 13:32:19,558 INFO 'status' command finished successfully

    Now, the machine is available on port 25565 (the default port!) Try to connect and this is what you get:

    I would have written this post sooner, but I was too busy “testing”

    Now, I know what you’re thinking. “But Marco, I want to configure the server, now I have to log in and configure it.” Nope! Juju Charms are configurable! To get a list of configuration options just run juju get minecraft which should produce the following list

    2011-11-16 13:31:06,718 INFO Connecting to environment.
    charm: minecraft-1
    service: minecraft
    settings:
        allow-nether:
            description: Allow generation of the nether, true or false
            type: string
            value: 'True'
        difficulty:
            description: Level of complexity 1-5
            type: int
            value: 1
        level-name:
            description: Name of the level, will be generated if it doesn't exist
            type: string
            value: world
        max-players:
            description: Maximum players allowed on the server
            type: int
            value: 10
        motd:
            description: Message of the day displayed to users in the server list
            type: string
            value: Juju Powered Minecraft Server
        port:
            description: Port for which Minecraft runs upon
            type: int
            value: 25565
        spawn-animals:
            description: Generate animals, true or false
            type: string
            value: 'True'
        spawn-monsters:
            description: Generate monsters, true or false
            type: string
            value: 'True'
    2011-11-16 13:31:07,473 INFO 'config_get' command finished successfully

    At this point you can update the configuration at any time using juju set minecraft option=value option2=value [...] an example to change the maximum players and the MOTD would be

    juju set minecraft motd="Juju I love you" max-players=5

    And in no time flat you’ll see something like this

    That about sums up getting started with launching Minecraft in Juju. It may seem like a lot but the majority of this was a one time setup. This is also just the tip of the iceburg when it comes to charms and Juju. I strongly recommend checking out their site and asking questions in the #juju room on freenode.