Amazon EC2 Driver 3.2

You should take into account the following technical considerations when using the EC2 cloud with OpenNebula: * There is no direct access to the dom0, so it cannot be monitored (we don't know where the VM is running on the EC2 cloud). * The usual OpenNebula functionality for snapshotting, restoring, or migration is not available with EC2. * By default OpenNebula will always launch small instances, unless otherwise specified. Please refer to the EC2 documentation to obtain more information about Amazon instances types and image management: * [[http://www.amazon.com/b?ie=UTF8&node=370375011 | General information of instances]] * [[http://developer.amazonwebservices.com/connect/entry.jspa?externalID=993 | Standard instances usage]] * [[http://developer.amazonwebservices.com/connect/entry!default.jspa?categoryID=112&externalID=1535&fromSearchPage=true | High CPU instances usage]] ====== EC2 Configuration ====== You must have a working account for [[http://www.amazon.com/AWS-home-page-Money/b?ie=UTF8&node=3435361 |AWS]] and signup for EC2 and S3 services, and also download and unpack the [[http://docs.amazonwebservices.com/AWSEC2/2008-02-01/GettingStartedGuide/ | EC2 API tools]] provided, do some manual test to verify everything works before start configuring OpenNebula for EC2 support. Please note that EC2 has to be installed only in the cluster front-end. ====== Driver Files ====== The driver consists of the following files: * ''/usr/lib/one/mads/one_im_ec2.rb'' : This file is accessed by the Information Manager to get the maximum memory and cpu constraints for EC2 allocations. * ''/usr/lib/one/mads/one_vmm_ec2.rb'': This is the main ruby program file that invokes EC2 actions like deploy, shutdown... * ''/etc/one/drivers/monitoring/ec2/ec2.conf'' : In this file we define the maximum capacity that we want to allocate in EC2. # Max number of instances that can be launched into EC2 SMALL_INSTANCES=5 LARGE_INSTANCES= EXTRALARGE_INSTANCES= * ''/etc/one/drivers/virtualization/ec2/ec2.conf'' : In this file we define default configurations for the VM placed in EC2, for example the "instancetype" attribute. * ''/etc/one/drivers/virtualization/ec2/ec2rc'' : In this file we configure the account that will be used to launch instances on EC2, these are the environment variables needed by the EC2 API. ====== Configuration ====== ===== OpenNebula Configuration ===== Two lines must be added to the ''/etc/one/oned.conf'' file in order to use the driver. IM_MAD = [ name = "im_ec2", executable = "one_im_ec2", arguments = "drivers/monitoring/ec2/ec2.conf", default = "drivers/monitoring/ec2/ec2.conf" ] VM_MAD = [ name = "vmm_ec2", executable = "one_vmm_ec2", arguments = " drivers/virtualization/ec2/ec2.conf", type = "xml" ] where //// can be used to set up the EC2 environment. It can be any number of the following flags, each corresponding to one EC2 environmental variable:
^ FLAG ^ SETs ^ | -u | EC2_URL | | -h | EC2_HOME | | -k | EC2_PRIVATE_KEY | | -c | EC2_CERT |
For instance, the following line will make the driver use a specific certificate to communicate with EC2: arguments = "-c /home/user/.ec2/ec2-cert.pem drivers/virtualization/ec2/ec2.conf", Make sure that the default configuration file (''ec2.conf'') is passed as the **last** argument. After configuring everything when you start ONE, you need to add the ec2 host to the host list to be able to submit virtual machines, like the following: $ onehost create ec2 im_ec2 vmm_ec2 tm_dummy dummy ===== Driver Configuration ===== Additionally you must configure the location of your EC2 certificates and EC2 API installation path, for this edit the file **/etc/one/drivers/virtualization/ec2/ec2rc** and add: EC2_HOME="" EC2_PRIVATE_KEY="" EC2_CERT="" Also you must configure the maximum capacity that you want OpenNebula to deploy on the EC2, for this edit the file **/etc/one/drivers/monitoring/ec2/ec2.conf** , in this example we say that we want at much 4 small and 1 large instances launched into EC2: # Max number of instances that can be launched into EC2 SMALL_INSTANCES=4 LARGE_INSTANCES=1 EXTRALARGE_INSTANCES= ====== EC2 Specific Template Attributes ====== ===== Mandatory Attributes ===== * **AMI**:the AMI name that will be launched * **KEYPAIR**: This attribute indicates the rsa key-pair used to initiate the machines, the private keypair later will be used to execute commands like //ssh -i id_keypair// or //scp -i id_keypair// ===== Optional Attributes ===== * **ELASTICIP**: This is the elastic IP address you want to assign to the instance launched. * **AUTHORIZED_PORTS**: this parameter is passed to the command //ec2-authorize default -p port//, and must be in the form of a number "22" or a range "22-90", * **INSTANCETYPE**: this atribute indicates the type of instace to be launched in EC2, by default all instances will be "m1.small". Remember valid values for this are m1.small, m1.large, m1.xlarge, c1.medium, c1.xlarge. ====== Multi EC2 Site Support ====== From OpenNebula 1.4 onwards it is possible to define various EC2 sites to allow opennebula the managing of EC2 availability zones or even the use of various private clouds offering EC2 interfaces. To properly configure multiple EC2 sites, you need to follow these steps: * define one VMM driver for each EC2 site, like: VM_MAD = [ name = "vmm_amazon_eu_west", executable = "one_vmm_ec2", arguments = "-u https://eu-west-1.ec2.amazonaws.com drivers/virtualization/ec2/ec2.conf", type = "xml" ] * create a host that uses the MAD defined above. The EC2 site will be incarnated in this host for OpenNebula. We will use the EC2 IM driver, the ad-hoc defined VM mad and a dummy TM (all images for EC2 must have been uploaded previously on S3): # onehost create ec2_eu_west im_ec2 vmm_amazon_eu_west tm_dummy dummy * create a host template with an EC2 section targeting the created EC2 site. OpenNebula 1.4 introduces a new tag (**CLOUD**) in the template's EC2 section for this purpose. You can create multiple EC2 sections so with one template you can define different AMIs depending on which host it is scheduled. EC2 = [ CLOUD="ec2_eu_west", AMI="ami-0022c769", AUTHORIZED_PORTS="22" ] EC2 = [ CLOUD="ec2_eu_east", AMI="ami-03324cc9", AUTHORIZED_PORTS="22" ] If you create another EC2 host called //ec2_eu_east// then you will have //ami-0022c769// launched when this VM template is sent to host //ec2_eu_west// and //ami-03324cc9// whenever the VM template is sent to host //ec2_eu_east//.
:!: If only one EC2 site is defined, the EC2 driver will deploy all EC2 templates onto it, not paying attention to the **CLOUD** attribute.
====== Testing ====== You must create a template file containing the information of the AMIs you want to launch, its important to note that when deploying VMs on EC2 with OpenNebula, the template file should contain the attributes AMI and KEYPAIR used by the EC2 VMM Mad. Additionally if you have an elastic IP address you want to use with your EC2 instances, you can specify it as an optional parameter. CPU = 0.5 MEMORY = 128 #Xen or KVM template machine, this will be use when submitting this VM to local resources OS = [kernel="/vmlinuz",initrd= "/initrd.img",root="sda1" ] DISK = [source="/imges/apache.img",target="sda",readonly="no"] NIC = [bridge="eth0"] #EC2 template machine, this will be use wen submitting this VM to EC2 EC2 = [ AMI="ami-00bafcb5", KEYPAIR="gsg-keypair", ELASTICIP="75.101.155.97", AUTHORIZED_PORTS="22", INSTANCETYPE=m1.small] #Add this if you want to use only EC2 cloud #REQUIREMENTS = 'NAME = "ec2"' You only can submit and control the template using the OpenNebula interface: $ onevm submit ec2template Now you can monitor the state of the VM with $ onevm list ID USER NAME STAT CPU MEM HOSTNAME TIME 0 oneadmin one-0 runn 0 0 ec2 00 00:07:03 Also you can see information (like IP address) related to the amazon instance launched via the command $ onevm show 0 VIRTUAL MACHINE 0 INFORMATION ID : 0 NAME : one-0 STATE : ACTIVE LCM_STATE : RUNNING START TIME : 07/17 19:15:17 END TIME : - DEPLOY ID: : i-53ad943a VIRTUAL MACHINE TEMPLATE EC2=[ AMI=ami-acc723c5, AUTHORIZED_PORTS=22 ] IP=ec2-174-129-94-206.compute-1.amazonaws.com NAME=one-0 VMID=0 You can check out the [[http://www.opennebula.org/doku.php?id=documentation:uc3#deploy_and_testing|EC2-ONE Use Case]] to see how to scale out a computing cluster with OpenNebula and EC2.