EC2 Driver Configuration Guide for ONE 1.0

You should take into account the following technical considerations:

  • There is no direct access to the dom0, so it cannot be monitored (we don't know where is running the VM on the EC2 cloud).
  • Since EC2 is beta, you can launch simultaneously at much 20 instances.
  • There is no snapshotting, restoring, migration functionality available by EC2.
  • Here are the size cost of the instances, by default OpenNebula will always launch small instances, unless specificated.
Cost per Hour RAM Virtual Cores HD platform
.10 € 1.7 GB 1 160 GB 32-bit
.40 € 7.5 GB 4 850 GB 64-bit
.80 € 15 GB 8 1690 GB 64-bit

Here you can find more information about Amazon instances types.

Requirements

You must have a working account for AWS and signup for EC2 and S3 services, and also download and unpack the EC2 Api tools provided, do some manual test to verify everything works before start configuring One for EC2 support.

Driver Files

Relative to $ONE_LOCATION:

  • bin/one_im_ec2.rb : This file is invoked by the Information Manager to get the maximum memory and cpu restrictions for EC2 clients.
  • bin/one_vmm_ec2.rb: This is the main ruby program file that uses the defined mad protocol to comunicate with the EC2, so deployments, shutdowns, etc are done here.
  • etc/im_ec2/im_ec2.conf : In this file we define the maximum capacity that we want for ec2, this is done because it could happen that you want at much a fixed number of instances running.
# Max number of instances that can be launched into EC2
SMALL_INSTANCES=5
LARGE_INSTANCES=
EXTRALARGE_INSTANCES=
  • etc/vmm_ec2/vmm_ec2.conf : In this file we define defaults configuration for instances launched with the vmm mad, i.e. the “instancetype” attribute.
# Default configuration attributes for the EC2 driver
# (all domains will use these values as defaults)
# Valid atributes are:
#  - ec2[keypair,instancetype]
#Example: EC2 = [ keypair="gsg-keypair", instancetype="m1.small"]

EC2 = [ instancetype="m1.small" ]
  • etc/vmm_ec2/vmm_ec2rc : In this file we configure the account that will be used to launch instances on EC2, this are the environment variables required by the EC2 Api to be executed.

OpenNebula Configuration

ONE Core Configuration

Two lines must be added to the $ONE_LOCATION/etc/oned.conf file in order to use the driver.

  IM_MAD = [name       = "im_ec2",
            executable = "bin/one_im_ec2",
            arguments  = "etc/im_ec2/im_ec2.conf",
            default    = "etc/im_ec2/im_ec2.conf" ]


  VM_MAD = [ name       = "vmm_ec2",
             executable = "bin/one_vmm_ec2",
             default    = "etc/vmm_ec2/vmm_ec2.conf",
             type       = "ec2" ]

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 following:

onehost add ec2 im_ec2 vmm_ec2

Driver Configuration

Additionally you must configure the location of your EC2 certificates and EC2 api installation path , for this edit the file $ONE_LOCATION/etc/mad/vmm_ec2rc and add:

EC2_HOME="/usr/local/ec2-api-tools-1.3-19403/"
EC2_PRIVATE_KEY="/home/lgonzalez/ec2/cert/pk.pem"
EC2_CERT="/home/lgonzalez/ec2/cert/cert.pem

Also you must configure the EC2 capacity that you want to provide when deploying over EC2, for this we mean the maximum capacity that you want the ONE Scheduler uses when deploying machines on the EC2, for this edit the file $ONE_LOCATION/etc/mad/im_dummy.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=

(for memory size and number of virtual cores by instance type see beginning of this guide)

EC2 Specific Template Attributes

Mandatory attributes:

  • AMI:the aminame 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

Non-mandatory-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.

(see template example below)

Testing

You must create a one template file containing the information of the AMIs you want to launch, its important to note that when deploying VMs on EC2 with ONE, 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 specificate 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-dcb054b5",
        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 = 'HOSTNAME = "ec2"'
  • The attributes, ELASTICIP, AUTHORIZED_PORTS and INSTANCETYPE are optional.
  • Then you only need to submit the template normally while ONE is running, and you'll get a EC2 instance:
onevm submit ec2template
  • Remember you can see information (like ip address) related to the ami launched via the command
$:onevm show 0

onevm show 0
VID            : 0
AID            : -1
TID            : -1
UID            : 0
STATE          : ACTIVE
LCM STATE      : RUNNING
DEPLOY ID      : i-1d04d674
MEMORY         : 0
CPU            : 0
PRIORITY       : -2147483648
RESCHEDULE     : 0
LAST RESCHEDULE: 0
LAST POLL      : 1216647834
START TIME     : 07/21 15:42:47
STOP TIME      : 01/01 01:00:00
NET TX         : 0
NET RX         : 0

....: Template :....
    CPU             : 1
    EC2             : AMI=ami-dcb054b5,AUTHORIZED_PORTS=22-25,ELASTICIP=75.101.155.97,INSTANCETYPE=m1.small,KEYPAIR=gsg-keypair
    IP              : ec2-75-101-155-97.compute-1.amazonaws.com
    MEMORY          : 1700
    NAME            : one-0
    REQUIREMENTS    : HOSTNAME = "ec2"

You can check out the EC2-ONE Use Case here.