In the previous post, I described how to use the vmc command-line tools to deploy a Ruby application to VMware’s cloud. In this post I will describe the steps I took to create and use a private cloud (based on the instructions found on github). If you have an account with Cloud Foundry, you can download a pre-built Micro Cloud Foundry, but by following these instructions you will have an environment similar to what I used in this project.
Creating a Micro Cloud Foundry
On a clean MacBook Pro running Snow Leopard (10.6.8), I downloaded an ISO to install 64-bit Ubuntu Server 10.4.3, then I installed VMware Fusion 4.1.1. I launched Fusion and started the process to create a new virtual machine:
- Introduction: I clicked the “continue without disk” button.
- Installation Media: I chose the disk image for Ubuntu Server.
- Operating System: I left the defaults of Linux and Ubuntu 64-bit.
- Linux Easy Install: I accepted the default user and specified a password (‘swordfish’).
- Tools Download: I downloaded the tools.
- Finish: I accepted the defaults (1 GB RAM, 20 GB hard disk, NAT networking).
- Save As: I named the virtual machine ‘My Cloud’.
- A few minutes later the server started and gave a login prompt.
It seems that Fusion’s easy install of Ubuntu does not get the keyboard properly mapped, so I entered the following command:
sudo dpkg-reconfigure console-setup
I selected the ‘Dell 101-key PC’ keyboard (pressing the <D> key repeatedly since the arrow keys didn’t work), and accepted the other default settings. I then entered the following commands (based in part on the instructions here) to update and install a few needed packages:
sudo apt-get update sudo apt-get upgrade sudo apt-get install vim sudo apt-get install openssh-server sudo apt-get install curl
Next, I entered the command to setup this Ubuntu server as a VMware Cloud Application Platform (VCAP):
bash < <(curl -s -k -B \ https://raw.github.com/cloudfoundry/vcap/master/dev_setup/bin/vcap_dev_setup)
This process took some time (an hour?) and when it finished it showed a message describing how to start Cloud Foundry:
~/cloudfoundry/vcap/dev_setup/bin/vcap_dev start
We now have the confusion of dealing with two machines (one real and one virtual) and so need to be careful to identify which one we mean in the subsequent instructions:
- Client: A MacBook Pro is my development machine, and a “client” with respect to “the cloud.” For this project, I interact with the client primarily using Terminal (using “a shell on the client”), but also using a web browser (Safari, Firefox, or Chrome) and the Finder.
- Server: VMware Cloud Application Platform (VCAP) runs on 64-bit Ubuntu in a Fusion virtual machine on the Mac, and provides “the cloud services” on a “Micro Cloud.” I interact with the server primarily using ssh in a Terminal session (“a shell on the server”), but occasionally using the console visible in Fusion. This micro cloud offers the same developer experience that a public cloud (such as appfog.com) should provide, so you can practice your deployment without making your application public.
In order to interact with the server using ssh in a Terminal session, we need to know the server’s IP address. On the server console, I entered the following command:
ifconfig eth0 | grep inet
The first line gives the IPv4 address (in my case, 192.168.10.128). On the client, I then entered the following command:
sudo vim /etc/hosts
to edit the client’s hosts file and add the following line:
192.168.10.128 mycloud
You should, of course, use the IP address you got from the server. Then, from a client shell, I entered the following to get a shell on the server:
ssh mycloud
I entered ‘yes’ to add the RSA key and then entered the password I defined when I built the server (‘swordfish’). To simplify my server commands, I added an alias using the following commands on the server:
echo "alias vcap='~/cloudfoundry/vcap/dev_setup/bin/vcap_dev'" >> ~/.bashrc source ~/.bashrc
On the server, I entered the following command:
vcap start
This gave me some debugging information, and ended with a list of services that all show as “RUNNING.”
Targeting the Micro Cloud
From the client we interact with a cloud using vmc, the command-line interface in a client shell. When we were using the public cloud, the “target” was api.cloudfoundry.com; with the micro cloud we use api.vcap.me as the target. VMware has registered the domain vcap.me and configured the DNS servers to map that domain (and all its subdomains) to 127.0.0.1 (or localhost). Of course, the micro cloud is not at 127.0.0.1 from the perspective of the client, so we need to establish a tunnel from port 80 on the client to port 80 on the server. First, we need to ensure that port 80 is not in use. On my Mac, I opened System Preferences, selected Sharing, and then made sure that ‘Web Sharing’ is unchecked. With port 80 available, I entered the following command in a client shell (replacing USER with the Ubuntu user defined during the initial setup):
sudo ssh -L 80:mycloud:80 USER@mycloud -N
This command establishes a tunnel from port 80 on the client to port 80 on the server, and the shell hangs until the tunnel is terminated (e.g., with <Ctrl>+<C>). To show that the cloud is there and responding, I entered http://api.vcap.me/info in a client web browser and observed the JSON data returned. In another client shell, I entered the following vmc commands (you should provide your own email!):
vmc target api.vcap.me vmc info vmc add-user --email jfoster@vmware.com --passwd swordfish vmc info
With the micro cloud up and running, I tried deploying my trivial Ruby application (described here) using the following client commands:
cd ~/env vmc push
In response to the questions, I named the application ‘jfoster-env’ and asked for 2 instances; otherwise I accepted the defaults. At this point (see notes below) I was able to see the application in a web browser at http://jfoster-env.vcap.me/ and http://jfoster-env.vcap.me/env and I tried the various vmc commands at the end of this post. The behavior was generally consistent with the public cloud.
Note 1: The first time I tried a push the response was “Error: Application [jfoster-env] failed to start, logs information below. Error 306: Error retrieving file ‘/logs/err.log.” I believe that this means that the application failed to start in time, and that when the system went to look for an error log, there wasn’t one. The application actually was running and responded to HTTP requests. Also, ‘vmc apps’ and ‘vmc stats jfoster-env’ showed the application running and ‘vmc restart jfoster-env’ reported success.
Note 2: The response to ‘vmc logs jfoster-env’ included “Error 306: Error retrieving file ‘logs/startup.log.” I found someone who said, “The file ‘logs/startup.log’ isn’t always generated, so the error returned by vmc can be a red herring.”
Conclusion
We have built an Ubuntu server and configured it as a private micro cloud. We used it as a target for our application and were able to use it in place of the public cloud. Next we will investigate adding a new runtime and framework to Cloud Foundry.
9 comments
Comments feed for this article
January 31, 2012 at 6:07 pm
Adding a Runtime and Framework to an older Cloud Foundry « Programming Gems (on GemStone)
[…] my previous post I described the process of build a private cloud using the “experimental” script […]
February 7, 2012 at 5:57 pm
Adding a Runtime and Framework to the New Cloud Foundry « Programming Gems (on GemStone)
[…] Chef-based installation (which appears to be the preferred method going forward), and I described how to create a private cloud following these instructions. In this post we will walk through the […]
February 17, 2012 at 12:27 pm
Adding Smalltalk to Cloud Foundry « Programming Gems (on GemStone)
[…] starting, you should create a private cloud (following the instructions here), and set up a client environment with VMC that recognizes Aida as a framework (as described […]
February 20, 2012 at 9:54 pm
Cloud Foundry install error: “no candidate version available for sun-java6-bin” « Programming Gems (on GemStone)
[…] I last followed the instructions for creating a private cloud, the vcap_dev_setup script completed without […]
February 21, 2012 at 9:57 pm
Video: Creating a Private Cloud « Programming Gems (on GemStone)
[…] video (6:53) is based on the blog post here and demonstrates the process for creating a private installation of Cloud Foundry. Having a private […]
March 11, 2012 at 8:25 pm
Using Chef to Instal GemStone/S in Cloud Foundry « Programming Gems (on GemStone)
[…] to install various components and we will install GemStone/S this way in our private cloud (created here). These steps will all take place in a shell on the […]
July 18, 2012 at 3:46 am
Ankit Goel
Hi James, I would like to thank you for detailing out each and every minute info. I am pretty new to CloudFoundry so some of my questions maybe trivial. Please ignore that.
I am presently trying to setup a private cloudfoundry instance by following your post. My question is – Can I use a Amazon EC2 Ubuntu machine instead of using a local VM? Will there be any implications when trying to push my applications on this private cloud from my local machine?
July 18, 2012 at 8:15 am
James Foster
Hi Ankit, I’m glad to hear of your interest in Cloud Foundry and to have your questions. While I have not tried using EC2 as a host for Cloud Foundry, if you have full access to the machine then it should be very similar. The first issue would be whether you can start with 64-bit Ubuntu Server 10.4. I used 10.4.3 and I see that 10.4.4 is the latest. I expect that should be fine, but I would not expect 12.4 to work without some modifications to the scripts. As to pushing applications to the cloud, it should be similar. The theory for a local VM is that it is just another IP address. Of course, if you can try out a local VM first, that will give you a test environment before pushing it to EC2.
July 3, 2013 at 1:56 pm
Creating a Micro Cloud Foundry v2 | Programming Gems (on GemStone)
[…] lot has happened with Cloud Foundry since I last blogged about creating a micro cloud (almost 18 months ago!). The Micro ”isn’t really […]