It has been a great learning opportunity for me and my colleagues to test our ideas. We started off with a bold idea. Our application would only live on the cloud. All collaboration, build out, testing would only happen on the cloud. Every developer would just be handed over a laptop and from then on, the next interaction would be with the cloud.
As a starting point, we wanted to model our SDLC (Software Development Lifecycle), around the following toolset.
- Starting development from a high end MAC, we wanted to compress our entire cloud application into one virtual machine
- Vagrant (along with Github) turned out to be the perfect choice for scripting and sharing our development environment with other programmers on the team
- Scripting our development environment itself was based around Chef-Solo (bundled along with Vagrant)
- Finally, an open source chef-server on Amazon-EC2 for creating and setting up nodes
- This (using open source chef-server, instead of relying on Amazon OpsWorks service) also keeps an option open for us to migrate away from Amazon-EC2 to another provider or a leased data center cloud in the future
The ride was not all smooth and rosy, and there were some good learning and experience that we built along the way.
Lets start off with the choice of MAC. We chose the 2.3 GHz mac with 16 GB wired memory. On this, our 64 Bit Ubuntu VM is provided with 4 GB memory. Inside of this Ubuntu VM, we run a bunch of application and database services (to be discussed in future). When we tried running on a slightly lower end MAC (2.0 GHz with 8 GB wired memory), there was appreciable slowdown in using the machine and the VM - leading to complaints from engineers and general loss of productivity. Lesson 1: in skimping out a development environment, ensure that you have a very high end client/ development laptop.
Even in the better client MAC, we see that heavy use of the development environment forces a shutdown ("Your MAC was restarted because of a problem") is unfortunately an occasional issue that crops up.
Moving on to Vagrant. The bundled in (and free!) VirtualBox provider is good enough to get started - however we soon learnt (running our application services), VirtualBox wasn't the right choice for stability and sharing code. Upgrading to the paid VMWare Fusion hypervisor and Vagrant VMWare provider plugin took care of that issue. However, re-running our scripts using VMWare's built in HGFS kernel module runs into issues; we need to delete and re-provision our virtual machine in order to trust the entire buildout.
This lead to another (related) issue - how do we make it cheaper to destroy and recreate our development VM's at will? Experimentation is in our development culture; and making it easier is something that encourages it further. We innovated by downloading and standardizing relevant (debian) packages to our MAC laptop, and then sharing the downloaded folder with our Vagrant VM. Two more steps got us the cheaper VM buildout we wanted:
- Adding the "shared" folder to "/etc/apt/sources.list"
- Changing chef recipes to run in "vagrant" mode; reading and changing attributes to help a cheaper build out
Relevant script for #1 is below:
#!/bin/bash
dpkg -i /home/vagrant/downloads/debs/chef_11.8.2-1.ubuntu.12.04_amd64.deb
dpkg -i /home/vagrant/downloads/dpkg-dev/*deb
if [ `grep -c /home/vagrant/downloads/debs /etc/apt/sources.list` -eq 0 ]; then
echo "deb file:/home/vagrant/downloads/debs /" \
| sudo tee -a /etc/apt/sources.list
fi
cd /home/vagrant/downloads/debs
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
sudo apt-get update
A relevant check for #2 is below:
In the next post, we will discuss setting up other parameters for setting up the cloud.
if node['chef-solo-var']['user'].eql?("vagrant")
// run vagrant env commands
else
// run cloud (amazon ec2) commands
end
In the next post, we will discuss setting up other parameters for setting up the cloud.