Something that Eucalyptus has been constant about from the beginning is its stance on being the best open source, on-premise AWS-compatible cloud on the market. This blog entry is just another example of demonstrating this compatibility.
My most recent blog entries have been centered around Docker and how to deploy it on Eucalyptus. This entry will show how a user can take Docker’s own documentation on deploying Docker using Vagrant with AWS - but with Eucalyptus. Before getting started, there are some prerequisites that need to be in place.
Prerequisites for Eucalyptus Cloud
In order to get started, the Eucalyptus cloud needs to have an Ubuntu Raring Cloud Image bundled, uploaded and registered before the steps below can be followed. The previous blog entries below will help here:
- Ubuntu Cloud Images and Eustore: The Eucalyptus Cloud Administrator’s Image Management Dream
- Step-by-Step Deployment of Docker on Eucalyptus 3.4 for the Cloud Administrator
In addition to the Ubuntu Raring Cloud EMI being available, the user also needs to have the following:
- a key pair to SSH into the instance
- proper Eucalyptus IAM policy to allow the following EC2 Actions:
- Launch permissions to launch the Ubuntu Raring Cloud EMI
- port 22 open in the security group where the instance will run
After these prerequisites have been met, the user is ready to set up Vagrant to interact with Eucalyptus.
Setting up Vagrant Environment
To start out, we need to set up the Vagrant environment. The steps below will get you going:
- Install Vagrant from http://www.vagrantup.com/. (optional – package manager can be used here instead)
- Install the vagrant aws plugin:
vagrant plugin install vagrant-aws
After Vagrant and the vagrant aws plugin have been successfully installed, all that is left is to create a Vagrantfile to provide information to Vagrant as to how to interact with Eucalyptus. Since the vagrant aws plugin is being used, and Eucalyptus is compatible with AWS, the configuration will be very similar to AWS.
I provided a Vagrantfile on Github to help get users up to speed quicker. To check out the Vagrantfile, just clone the repository from Github:
$ git clone https://github.com/hspencer77/eucalyptus-docker-raring.git
After checking out the file, change directory to eucalyptus-docker-raring, and edit the following variables to match your user information for the Eucalyptus cloud that will run the Docker instance:
AWS_ENDPOINT = "<EC2_URL for Eucalyptus Cloud>" AWS_AMI = "<ID for Ubuntu Raring EMI>" AWS_ACCESS_KEY = "<Access Key ID>" AWS_SECRET_KEY = "<Secret Key>" AWS_KEYPAIR_NAME = "<Key Pair name>" AWS_INSTANCE_TYPE = '<VM type>' SSH_PRIVKEY_PATH = "<The path to the private key for the named keypair, for example ~/.ssh/docker.pem>"
Once the Vagrantfile is populated with the correct information, we are now ready to launch the Docker instance.
Launch the Docker Instance Using Vagrant
From here, Vagrant makes this very straight-forward. There are only two steps to launch the Docker instance.
- Run the following command to launch the instance:
vagrant up --provider=aws
- After Vagrant finishes deploying the instance, SSH into the instance:
Thats it! Once you are SSHed into the instance, to run Docker, execute the following command:
ubuntu@euca-172-17-120-212:~$ sudo docker
You have successfully launched a Docker instance on Eucalyptus using Vagrant. Since Eucalyptus works with the vagrant aws plugin, the same Vagrantfile can be used against AWS (of course, the values for the variables above will change). This is a perfect dev/test to production setup whether Eucalyptus is being used for dev/test and AWS being used for production (and vise versa).