Beginning cloud development with cloudControl

##.

Don’t forget to grab the other parts as well:


So you’ve heard all about the cloud. In the current day and age, you’d have to be living under a rock to have not encountered it by now. Whether it’s the ads from Amazon, Rackspace or Microsoft, the extensions to your favourite framework, such as SimpleCloud in Zend Framework or iCloud from Apple – The Cloud is Everywhere!

But these aren’t the only options available to us as developers. In this series I want to introduce you to and help you get started with another cloud service - cloudControl.


##.

Don’t forget to grab the other parts as well:


So you’ve heard all about the cloud. In the current day and age, you’d have to be living under a rock to have not encountered it by now. Whether it’s the ads from Amazon, Rackspace or Microsoft, the extensions to your favourite framework, such as SimpleCloud in Zend Framework or iCloud from Apple – The Cloud is Everywhere!

But these aren’t the only options available to us as developers. In this series I want to introduce you to and help you get started with another cloud service - cloudControl.

We’re going to build a simple user list application where we can

add, edit, delete and list users for a small, company.

The application will use some of the cloudControl core features, including:

  • Aliases
  • MySQL
  • Memcached
  • MongoDB

Through doing this we’re going to get a good overview of what it takes to build an application, how to work with the web interface and command line tools and to push and deploy our changes out and see them live. So with that, let’s get started with cloudControl.

Requirements

To follow along with this series, you’re going to need the following tools:

  • Python
  • Git
  • An ssh public key

This tutorial is being carried out under Mac OSX but will work equally well if you’re using Linux.

Windows

If you’re on Windows please have a look at the Windows setup page. You’ll need to download the Windows Installer and install the Microsoft Visual C++ 2008 Redistributable Package (x86) to get started.

What is cloudControl 

cloudControl is a service that I came across recently and was pretty impressed with right from the get-go. Based out of Berlin, Germany, cloudControl is a service that allows you to develop and deploy to the cloud hassle free and when you need more power, autoscale accordingly.

More specifically, cloudControl is a Platform as a Service (PaaS). According to wikipedia, a PaaS is:

A category of cloud computing services that provide a computing platform and a solution stack as a service. In the classic layered model of cloud computing, the PaaS layer lies between the Software as a Service (SaaS) and the Infrastructure as a Service (IaaS) layers.

PaaS offerings facilitate the deployment of applications without the cost and complexity of buying and managing the underlying hardware and software and provisioning hosting capabilities, providing all of the facilities required to support the complete life cycle of building and delivering web applications and services entirely available from the internet.

Well that’s exactly what cloudControl allows us as developers to do. It provides the infrastructure and hosting provisioning capabilities that allow us to deploy our applications to the web with a minimum of hassle, effort and time.

In this introductory post on cloudControl, I’m going to give you a rapid overview on getting started with the service. By the time we’re finished, you’ll have your first, introductory, application developed and deployed to the cloud, ready for the world to use.

Pricing

Pricing for the service is based on two key criteria:

  • Number of boxes
  • Number and type of add-ons

Boxes

A box is what you would normally think of when hosting your web applications - they’re effectively a standard server or VPS, running your code, responding to HTTP requests. All accounts get one box free which can host unlimited applications and receive unlimited traffic. You can then nominate to have more than one box be available for autoscaling as needed to handle performance spikes as and when they occur - de-scaling when the load subsides.

One box will be sufficient for the purposes of this tutorial series. However, in later posts, we may look at scaling across multiple boxes to simulate how the service responds when needed.

Add-ons

Besides one ore more boxes, with cloudControl, you get the following optional add-ons:

  • MongoDB
  • MySQL
  • Memcached
  • SSL
  • Cron – available for either hourly or daily jobs
  • Workers – Allow you to perform extra work as required
  • Xeround Cloud Database – an elastic, always-on cloud database that lets you run your MySQL applications in the cloud
  • New Relic – The only tool you need to pinpoint and solve performance issues in your code – regardless of language.
  • Aliases

With all these features, you can deploy pretty robust applications that expand and shrink as needed to meet your demand requirements and allow you to monitor performance intimately. Now, on to the getting started steps.

To determine the amount you’ll be paying per/month, consult the pricing calculator, which is very simple to use.


Creating the basic application

Step 1 - Signing Up for An Account

In your browser of choice, head on over to the sign-up page at http://cloudcontrol.com/sign-up/. When you’re there, enter your primary account details:

  • username
  • email address
  • password
cloudControl account signup
<p class="wp-caption-text">
  cloudControl account signup
</p>

Once you’ve submitted this form, you’ll receive an account confirmation email to the email address that you entered and your account activation code. Clicking on the link will take you to the account activation form. Enter the activation code that you received and click &’Activate&’ and your account is ready to use.

Step 2 - Login to your account

After you activate your account, you’re taken to the confirmation page which contains the login form. Login and you’ll see the details for your account.

activate your cloudControl account

activate your cloudControl account

Step 3 - Create a Local Project

Now, in the current iteration cloudControl involves a fair amount of command-line interaction. But this can be easily automated whether through shell scripts or when integrated with a CI server such as Hudson, Cruise Control or Webistrano. But for the remainder of this script, there’s going to be a bit of command-line work, so open up that terminal and let’s continue.

Open up the App Quickstart and install the base package. The commands are:

[bash] # install the cctrl application sudo easy_install cctrl # create a public key (if required) ssh-keygen -b 2048 # add the public key to the cloudControl account cctrluser key.add ~/.ssh/id_rsa.pub # add the public key to the user agent ssh-add [/bash]

Now, in your project directory, create the file index.php with the following content:

[html]

Malt Blue / Cloud Control :: Test Project

Malt Blue / Cloud Control :: Test Project

Hello World

[/html]

Now, with git, stage the file and then commit it to the project. The following commands will suffice:

[bash] git init git add index.php git commit -m &‘First addition of the bootstrap file to the project’ [/bash]

You’ll see the file be staged and committed to your local repository. All being well, there were no errors. If there weren’t, continue along to step 4.

Step 4 - Commit the local changes

Ok, now that the base foundation is out of the way, cd to your local branch and run the following commands, where APP_NAME is the name of your application. For the purposes of this tutorial, it will be maltbluedev. So run the following commands:

[bash] # create the application in cloudControl cctrlapp maltbluedev create php [/bash]

We’ve now configured our project to use cloudControl to deploy to.

Step 5 - Propogating & Deploying changes to cloudControl

Ok, we’re getting close to being done. Now we need to propagate the changes to cloudControl and then deploy the changes to our deployment environment. In the terminal, run the following two commands:

[bash] # pushes the changes to cloudControl cctrlapp maltbluedev/default push # deploys our latest changes to our live environment cctrlapp maltbluedev/default deploy [/bash]

Deploying changes to cloudControl

Deploying changes to cloudControl

Step 6 - Viewing the running site

Now that the latest changes have been deployed, we’re ready to view our first site. To do that, go to: http://maltbluedev.cloudcontrolled.com. When you’re there, you’ll see a page just like the following:

Viewing the running cloudControl app

Viewing the running cloudControl app

Staging Environments

The initial, or first deployment, is always called default, this is effectively your live environment. However, in normal development practice we have multiple environments, i.e., testing, staging etc. But how do you achieve this in a fluid manner with cloudControl.

To setup multiple environments, all you need to do is to create a branch in your repository for each environment that you require. Following that, you need to create a new deployment and propagate and push the changes out to it. After this, you’ll then have the respective environments ready to use. They’ll be available via the following URI syntax:

http://ENVIRONMENT_NAME.APP_NAME.cloudcontrolled.com

As a simple example, I’ve created a staging environment for our simple project. In the screenshots below, you can see that I’ve done the following:

  • Created the new staging branch
  • Switched to it
  • Made a change to index.php
  • Committed it to the repository
  • Created a staging deployment
  • Propagated the changes to cloudControl
Creating a staging environment in cloudControl

Creating a staging environment in cloudControl

The Staging Version

Only one thing to do - view the staging version of the site. In the final screenshot below, you can see the staging version of the site, with the slightly amended html. Now you can see the staging environment at: http://staging.maltbluedev.cloudcontrolled.com. Nothing could be simpler.

The deployed staging version on cloudControl

The deployed staging version on cloudControl

We’re Done

What could be simpler? Not much really. Now this has been a simple example, but it really shows the power of cloudControl.

  • You don’t need to have all the infrastructure all the time
  • You don’t need to be a master systems administrator nor have a dedicated staff of them
  • You don’t need to know the ins and outs of all the latest technologies
  • It’s painlessly simple to setup and deploy multiple environments

Through simple commands that are automatable with either a proper deployment script or continuous integration server, you can have what you need as you need it and autoscale as your needs demand.

Where to from here

I’m sure you’ll agree that this first example is pretty simple. So what about adding in a database backend? In part 2, we really start to put the application together - and we’re starting with MySQL.

This is a 4 part series.

Don’t forget to grab the other parts as well:


You might also be interested in these tutorials too...

Fri, Dec 16, 2011

Beginning cloud development with cloudControl - Part 2 - MySQL

In part one of the series we got a birds eye view of a great cloud development solution for PHP - cloudControl. We looked at the concept of what it is, what you can do with it and ran through a basic deployment with a rather basic application. If you missed the first part, I strongly encourage you to read it before continuing on with part two. When you’re done, come on back and work through it here.

In this, part two of the series, things start to get more serious. In this part, we’re going to start to flesh out the application started in part one, adding in MySQL support - showing just how simple cloudControl makes this for us.

Mon, Jan 9, 2012

Beginning cloud development with cloudControl – Part 4 – Memcache

Here we are at part four of the Beginning Cloud Development with cloudControl series and in this part, we’re adding Memcached support. In part one of the series, we laid the foundation for the application and got up to speed with what cloudControl is, why it works and how to get started using it.

Then in part two, we started to flesh out the application that we started building in part one and added MySQL support to it. We showed how to work with cloudControl to manage the key requirements, such as enabling MySQL support, connecting to the MySQL database and keeping the database up to date from a maintenance perspective (creating the database schema and loading data in to the database).

Then in the third part of the series, we replaced MySQL with mongoDB support. Now, in this, the third part of the series, we’re going to finish up with adding Memcached support. As the core of the work’s already been done in the application, this tutorial will be shorter and simpler than the previous three. So, get out the code that you worked through from part 2, or download a copy of it from the github repository and let’s get started.

Mon, Jan 2, 2012

Beginning cloud development with cloudControl – Part 3 – MongoDB

Here we are at part three of the beginning cloud development with cloudControl series and in this part, we’re adding mongoDB support. In part one of the series, we laid the foundation for the application and got up to speed with what cloudControl is, why it works and how to get started using it.

Then in part two, we started to flesh out the application that we started building in part one and added MySQL support to it. We showed how to work with cloudControl to manage the key requirements, such as enabling MySQL support, connecting to the MySQL database and keeping the database up to date from a maintenance perspective (creating the database schema and loading data in to the database).

In this, the third part of the series, we’re replacing MySQL that we introduced in part two with mongoDB support.

Tue, May 22, 2012

Zend Form Mastery with Zend Config – Part 3 Standard Form &amp; Element Options

– Part 3 Standard Form & Element Options This is a Multi Part Series. Check out the other parts: Part 1 - Custom Filter Paths Part 2 - Core Form Configuration Part 4 - Configuring Zend Validators Options We’ve looked at custom form filters and we’ve looked at the core form configuration. But what about the other form properties? What about: setting an element as readonly an element as required ignoring an element and love them or hate them, what about decorators Element Options Outside of the options that we’ve looked at previously, there are a number of other options that we can consider implementing when configuring a Zend Form.


Want more tutorials like this?

If so, enter your email address in the field below and click subscribe.

You can unsubscribe at any time by clicking the link in the footer of the emails you'll receive. Here's my privacy policy, if you'd like to know more. I use Mailchimp to send emails. You can learn more about their privacy practices here.

Join the discussion

comments powered by Disqus