Atlassian doesn't provide support for customized images. Bamboo provides flexibility to use customized machine images, but it's impossible for us to support all individual configurations.
Use Bamboo stock images as the base for all image customizations to ensure a minimal level of consistency of your Elastic Bamboo setup.
An elastic image is an Amazon Machine Image (AMI) that is stored in one of Amazon data centers 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.
Amazon Web Services (AWS) に登録されたエラスティック イメージのそれぞれに、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.
大まかに言うと、カスタム エラスティック イメージを作成するプロセスでは、Amazon EC2 で利用可能な既存の Amazon Machine Image (AMI) の 1 つを取得し、その AMI のインスタンスを起動し、インスタンスをカスタマイズしてから、カスタマイズ後のインスタンスからイメージを作成します。このイメージは、Bamboo インストールでエラスティック イメージとして使用できます。
カスタム イメージを作成する代わりに次のことを検討してください (Linux/UNIX のみ)。
- Bamboo 管理 / イメージ設定に用意されているインスタンス設定スクリプトを使用できます。このスクリプトは、エージェントが起動する前にルート ユーザーとして実行されるものです。
- Consider customizing an existing Bamboo image by using Amazon's Elastic Block Store (EBS), as described in Configuring elastic instances to use the EBS.
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.
始める前に
- これは簡単な手順ではなく、おそらく必要ないでしょう。
- アトラシアンはカスタム エラスティック イメージをサポートしていません。代わりに、ストック イメージから作成したエラスティック エージェントをカスタマイズすることを検討してください。
- A number of the EC2 commands in the steps below can be completed using the AWS console rather than command line tools (e.g. registering an image). You should use the method you're feel most comfortable with.
On this page:
1. 要件
まず、次の設定が完了していることを確認してください。
- Amazon Web Services (AWS) account with EC2 — if you are already using Elastic Bamboo, you should already have an AWS account with EC2 set up. If not, please read Getting started with Elastic Bamboo.
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
— インストール済みの EC2 API ツールのパスに設定しますEC2_CERT
— EC2 アカウントに割り当てられた証明書のパスに設定します。EC2_PRIVATE_KEY
— AWS アカウントに割り当てられた非公開キーのパスに設定します。
登録済みキー ペア — AMI インスタンスで EC2 API ツールを使用するには、非公開キー ファイルと証明書ファイルで構成される登録済み EC2 キー ペアが必要です。以前に EC2 キー ペアを生成して登録したことがある場合は (EC2 API ツールを使用するためなど)、それを再利用できます。新しいキー ペアを生成する必要がある場合は、次のコマンドを使用して生成できます。
ec2-add-keypair <key_pair_name>
非公開キーの内容はコンソールのコマンド ライン出力に表示されます。この内容を先頭に次の行を追加してファイルに保存します。
"--BEGIN RSA PRIVATE KEY--"末尾には次の行を追加します。
"--END RSA PRIVATE KEY--"この非公開キー ファイルは、AMI インスタンスへのアクセスに使用されます。次のコマンドを実行して、非公開キー ファイルに対する適切な権限を設定します。
chmod 600 <private_key_file>
2.既存の AMI を選択する
空白の AMI から始めるのではなく、既存の Linux/UNIX AMI を選択してカスタマイズすることを強くお勧めします。AMI を選択する際には、カスタム エラスティック イメージから 32 ビットと 64 ビットのどちらのインスタンスを起動するかを決定し、その選択に適合する既存の AMI を選択してください。
カスタマイズに推奨される既存の Linux/UNIX AMI は次のとおりです (優先度が高い順)。
ソース | 説明 | AMI リスト |
---|---|---|
アトラシアン | 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. | Bamboo インスタンスの管理 / イメージ設定で利用可能 |
Amazon | Amazon から提供されている Centos ベースのイメージ。Bamboo の前提条件はインストールされていません。通常は、アトラシアンの AMI を使用することをお勧めします。 | Amazon のサイト |
Canonical (Ubuntu) | Canonical (Ubuntu Linux プロジェクトの背後にある会社) から提供されている公式の Ubuntu イメージです。Bamboo の前提条件はインストールされていません。 | Canonical のサイト |
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 labeled with "(stock image)".
3.インスタンスを起動する
カスタマイズ対象の既存の AMI を選択したら、次のステップは AMI のインスタンスを起動することです。
3.1 アトラシアンの既定の AMI のインスタンスを起動する
If you chose to customize Atlassian's default AMI, you will have to start the instance from the admin section of Bamboo. See Starting an elastic instance.
アトラシアンの既定の AMI は、コマンド ラインの ec2 ツールでは起動できません。これは、起動時に、アトラシアンの AMI の Bamboo エージェントによって、それが Bamboo Server から起動されたかどうかが確認され、そうでない場合はすぐにシャットダウンされるためです。
Once started, see Accessing an elastic instance for details on how to access the running instance.
3.2 コマンド ラインからインスタンスを起動する
次のように、ec2-run-instances
コマンドを使用してインスタンスを起動します。
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.
たとえば、キー ペア my-keypair
を使用してイメージ ami-e55bbd8c
のインスタンスを起動する場合は、次のコマンドを実行します。
ec2-run-instances ami-e55bbd8c -k my-keypair
このコマンドのコマンド ライン出力は次のとおりです。
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.
使用されていないインスタンスをシャットダウンすることを忘れないでください。
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.
3.3 Bamboo からインスタンスを起動する
また、カスタマイズされていないイメージを Bamboo から新しく作成して、カスタマイズを開始することもできます。この方法の欠点は、わずか 40 分後に Bamboo によってインスタンスがシャットダウンされることです。利点は、エージェントを 1 つのステップでカスタマイズできることです (イメージをカスタマイズまたは作成し、Bamboo から起動し、イメージを再び保存する必要はありません)。
4.インスタンスにアクセスする
If you started the instance from Bamboo, see Accessing an elastic instance for details on how to access the running instance.
インスタンスが実行されていれば、インスタンスにアクセスできるようにインスタンスのアドレスを取得する必要があります。そのためには、次のコマンドを使用します。
ec2-describe-instances <instance_name>
たとえば、インスタンス i-25b86743
のアドレスを調べるには、次のように入力します。
ec2-describe-instances i-25b86743
このコマンドのコマンド ライン出力は次のようになります。
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
上記の例のインスタンスのアドレスは 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:
- replace
/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
を対象のインスタンスのアドレスに置き換えます。
5.インスタンスをカスタマイズする
Now that you have a running instance, customization steps heavily depend on the operating system you're using. We've prepared separate pages with Linux-specific instructions and Windows-specific instructions.
6.カスタマイズしたインスタンスのイメージを作成する
新しいイメージを作成するプロセスは、イメージがインスタンス ストアと EBS ルート イメージのどちらに基づいているかによって異なります。イメージのタイプは、AWS コンソールまたは ec2-describe-images を使用して確認できます。
EBS ルート インスタンスからイメージを作成する
See here for instructions: Amazon Tutorial
インスタンス ストア (S3) インスタンスからイメージを作成する
最後のステップは、カスタマイズしたインスタンスからイメージを作成することです。そのためには、次の情報が必要です。
- Amazon アカウント番号
- アクセス キー ID
- シークレット アクセス キー
- Amazon S3 bucket name that will be used to store image (if you don't have access to Amazon S3, you can sign up on this page.)
Amazon 非公開キー ファイルと証明書をインスタンスに転送します。
キー ファイルをインスタンスに転送するには、ローカル マシンで次のコマンドを実行します。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'.
EC2_HOME および JAVA_HOME 環境変数を設定します。
これらの環境変数を設定するには、インスタンスで次のコマンドを実行します。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>
次のように、
ec2-bundle-vol
コマンドを使用して、カスタマイズしたインスタンスのイメージを作成できます。ec2-bundle-vol -c $EC2_CERT -k $EC2_PRIVATE_KEY -u <amazon_account_number> -p <elastic_image_name> --batch --debug
ここで、<elastic_image_name> は、カスタム イメージに割り当てる名前です (「CustomImage1」など)。
イメージが作成されたら、次のコマンドを実行して Amazon S3 にアップロードする必要があります。
ec2-upload-bundle -b <s3_bucket_name> -m /tmp/<elastic_image_name>.manifest.xml -a <access_key_id> -s <secret_access_key> --retry --debug
ここで、<s3_bucket_name>、<access_key_id>、<secret_access_key> は、前述の Amazon S3 バケット名、アクセス キー ID、シークレット アクセス キーです。<elastic_image_name> は、カスタム イメージに割り当てる名前です (「CustomImage1」)。
次に、
ec2-register
コマンドを使用して、Amazon EC2 にイメージを登録する必要があります。ec2-register <s3_bucket_name>/<elastic_image_name>.manifest.xml
ここで、<s3_bucket_name> は、前述の Amazon S3 バケット名です。<elastic_image_name> は、カスタム イメージに割り当てる名前です (「CustomImage1」)。このコマンドの出力には、カスタム イメージの AMI ID が表示されます。
7. 次のステップ
カスタム エラスティック イメージの作成が終了したら、それを使用できるようにするために、さらに 2 つのステップを完了する必要があります。
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.
8. お困りですか?
さらに支援が必要な場合は、次のようなリソースを活用できます。
- AWS Support Center — if you are having problems with any of your Amazon services, not specifically related to Bamboo, you can obtain basic support from the AWS Support Center. Note, you will need to sign up for Premium Support to get access to web/phone support.
- AWS Resource Center — the AWS Resource Center has links to online documentation, code samples and tools for AWS services.
- Bamboo Developer Forums — please feel free to discuss any useful tips or issues regarding this process in the Bamboo Developer Forums.