[Bamboo Cloud docs]
[Bamboo Knowledge Base]
An elastic image is an Amazon Machine Image (AMI) that is stored in one of Amazon data centres for use with the Elastic Bamboo feature. An elastic image is used to create elastic instances, which in turn create elastic agents. Conceptually, an elastic image is equivalent to an operating system running on a computer's boot hard drive and elastic instances would be the software that runs on this operation system.
Each elastic image registered with the Amazon Web Services (AWS) has its own unique identifier, known as an AMI ID.
You can associate multiple elastic images with a Bamboo server. One default shared image is maintained by Atlassian in AWS, and is available to all Elastic Bamboo users.
At a high level, the process for creating a custom elastic image consists of taking one of the existing Amazon Machine Images (AMIs) available on Amazon EC2, starting an instance of the AMI, customising the instance and then creating an image from the customised instance. This image can then be used as an elastic image in your Bamboo installation.
Instead of creating a custom image (Linux/UNIX only):
Above options are much simpler than creating a new custom image. If you are having problems, please don't hesitate to contact us for further help.
Before you begin:
On this page:
First ensure that you have set up the following:
Amazon EC2 API Tools — you must install the EC2 API tools on your local machine, otherwise you will not be able to start and access your AMI instance. Note: you need Java Runtime Environment to run these tools. You can install the EC2 API tools by executing the following commands:
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip unzip ec2-api-tools.zip
EC2_HOME
— set this to the path to the installed EC2 API ToolsEC2_CERT
— set this to the path to the certificate assigned to EC2 accountEC2_PRIVATE_KEY
— set this to the path to the private key assigned to your AWS accountRegistered Key Pair— you need a registered EC2 key pair, which consists of a private key file and certificate file, to use the EC2 API tools with your AMI instance. If you have previously generated and registered an EC2 key pair (e.g. to use the EC2 API tools), you can re-use it. If you need to generate a new key pair, you can use the following command to do so:
ec2-add-keypair <key_pair_name>
The content of the private key will be displayed in the command-line output on your console. Save this content in a file , starting with the line:
"--BEGIN RSA PRIVATE KEY--"and ending with the line:
"--END RSA PRIVATE KEY--"This private key file will be used to access your AMI instance. Set up the appropriate permissions on the private key file by executing the following command:
chmod 600 <private_key_file>
We strongly recommend that you select an existing Linux/UNIX AMI to customise, rather than starting with a blank AMI. When choosing an AMI, decide whether you want to launch 32-bit or 64-bit instances from your custom elastic image and select an existing AMI matching your choice.
We recommend the following existing Linux/UNIX AMIs for customisation (in order of preference):
Source | Description | AMI list |
---|---|---|
Atlassian | One of the stock images provided by Atlassian. It is an Amazon image, for either Linux or Windows, updated and prepared for Bamboo, i.e. you will not have to install any Bamboo prerequisites. | Available on your Bamboo instance under Administration/Image Configurations |
Amazon | CentOS-based image provided by Amazon. It does not have any Bamboo prerequisites installed. Typically, you will be better off using the Atlassian AMI. | Amazon's site |
Canonical(Ubuntu) | An official Ubuntu image provided by Canonical (the company behind the Ubuntu Linux project). It does not have any Bamboo prerequisites installed. | Canonical's site |
Atlassian's AMIs (and hence, their IDs) may change with each release of Bamboo, including both major and minor releases. To quickly access Atlassian's AMI IDs for your currently-running version of Bamboo, open that Bamboo site in a web browser and access its 'Image Configurations' page (see Managing your Elastic Image Configurations for more information). The AMI IDs of Atlassian's AMIs are labelled with "(stock image)".
After you have selected an existing AMI to customise, the next step is to start an instance of the AMI.
If you chose to customise Atlassian's default AMI, you will have to start the instance from the admin section of Bamboo. See Starting an elastic instance.
Note that Atlassian's default AMI cannot be started using the command line ec2 tools. This is because, on start up, the Bamboo agent on Atlassian's AMI checks to see if it was started from a Bamboo server, and immediately shuts itself down if it was not.
Once started, see Accessing an elastic instance for details on how to access the running instance.
Use the ec2-run-instances
command to start your instance, as follows:
ec2-run-instances <image_name> -k <key_pair_name>
where <image_name>
is the name of the AMI selected in the previous step and <key_pair_name>
is the name of the registered key pair generated in '1. Requirements'. The public certificate of this key will be injected into your instance.
For example, if you wanted to start an instance of image ami-e55bbd8c
using key pair my-keypair
, you would run the following command:
ec2-run-instances ami-e55bbd8c -k my-keypair
This command would produce the following command-line output:
INSTANCE i-25b86743 ami-e55bbd8c running my-keypair
i-25b86743
is the name of the new instance in the above example. You should note down the name of your new instance, as you will need that to access your instance in the next step.
Don't forget to shut down unused instances
Please note that once you start an instance, you will be billed by Amazon for instance uptime. If you decide to abandon the setup of a custom elastic image after this step, please ensure that you shut down your instance via the AWS console.
You can also start a fresh, uncustomised image from Bamboo and begin customisation. The drawback of this approach is that you have only 40 minutes before Bamboo shuts down your instance. The advantage is that you can customise the agent in a single step (as opposed to having to customise/create image/start from Bamboo/save image again).
If you started the instance from Bamboo, see Accessing an elastic instance for details on how to access the running instance.
Once your instance is running, you will need to obtain the address of the instance so you can access it. To do this, use the following command:
ec2-describe-instances <instance_name>
For example, if you wanted to find the address of instance i-25b86743
, you would enter:
ec2-describe-instances i-25b86743
This command would produce the following command-line output similar to this:
RESERVATION r-790f7210 121852097033 default INSTANCE i-25b86743 ami-e55bbd8c ec2-174-129-94-241.compute-1.amazonaws.com domU-12-31-39-04-38-87.compute-1.internal running elasticbamboo 0 m1.small 2009-06-24T12:36:20+0000 us-east-1c aki-a71cf9ce ari-a51cf9cc monitoring-disabled
The address of the instance in the above example is ec2-174-129-94-241.compute-1.amazonaws.com
You can then use this address to access the instance via SSH. See Accessing an elastic instance for instructions. If you are using the example command text from that document, you will need to adjust it as follows:
/opt/bamboo/home/xml-data/configuration/elasticbamboo.pk
in the example command text with the private key file you generated in '1. Requirements'.ec2-68-111-185-197.compute-1.amazonaws.com
in the example command text with the address of your instance.Now that you have a running instance, customisation steps heavily depend on the operating system you're using. We've prepared separate pages with Linux-specific instructions and Windows-specific instructions.
The process of creating a new image varies depending whether you based your image on an instance-store or EBS-root image. You can check your image type via AWS console or using ec2-describe-images.
See here for instructions: Amazon Tutorial
The final step is to create an image from your customised instance. To do this, you will require the following information:
Transfer Amazon private key file and certificate to your instance
Transfer the key files to your instance by running these commands on your local machine:
scp -i <private_key_file> $EC2_PRIVATE_KEY root@<instance_address>:/mnt scp -i <private_key_file> $EC2_CERT root@<instance_address>:/mnt
where <private_key_file> is the private key file from your local machine created in step 'Registered Key Pair' of 1. Requirements and the <instance_address> is the address of your instance from '4. Accessing your Instance'.
Set up EC2_HOME and JAVA_HOME environment variables
Set up these environment variables by running the following commands on your instance:
export EC2_HOME=<location of your EC2 tools installation> export EC2_PRIVATE_KEY=/mnt/<ec2_private_key_file> export EC2_CERT=/mnt/<ec2_certificate_file> export JAVA_HOME=<path to JRE used to start the agent>
You can create an image of your customised instance by using the ec2-bundle-vol
command, as follows:
ec2-bundle-vol -c $EC2_CERT -k $EC2_PRIVATE_KEY -u <amazon_account_number> -p <elastic_image_name> --batch --debug
where <elastic_image_name> is the name that you want to assign to your custom image (e.g. 'CustomImage1')
Once the image is created, you need to upload it to Amazon S3 by running the command below:
ec2-upload-bundle -b <s3_bucket_name> -m /tmp/<elastic_image_name>.manifest.xml -a <access_key_id> -s <secret_access_key> --retry --debug
where <s3_bucket_name>, <access_key_id> and <secret_access_key> are the Amazon S3 bucket name, Access Key ID and Secret Access Key described previously, and <elastic_image_name> is the name that you want to assign to your custom image (e.g. 'CustomImage1').
You will then need to register your image with Amazon EC2 by using the ec2-register
command:
ec2-register <s3_bucket_name>/<elastic_image_name>.manifest.xml
where <s3_bucket_name> is the Amazon S3 bucket name described previously and <elastic_image_name> is the name that you want to assign to your custom image (e.g. 'CustomImage1'). The output of this command will show the AMI ID of your custom image.
Now that you have created a custom elastic image, there are two more steps that you will need to complete before you can use it.
First, you will need to associate your custom elastic image with your Bamboo installation by creating an Elastic Image Configuration. Please note the AMI ID of your new custom image and read Managing your Elastic Image Configurations for further instructions.
Secondly, you will need to configure the capabilities of the elastic agents that will run on instances started from your image. This is done by adding the appropriate builder, JDK, Perforce and custom capabilities to your elastic image configuration, so that it reflects what your custom elastic image actually can do. For example, if you have created a custom elastic image with JDK 1.6 and Maven 2 installed, you will need to add capabilities for JDK 1.6 and Maven 2 to the elastic image configuration. Read Configuring Elastic Agent Capabilities for further instructions.
If you need more help, there are a number of resources that you can take advantage of: