CDP:Bootstrap Pattern
Automatic Acquisition of Startup Settings
Contents |
Problem to Be Solved
There has often been debate over how frequently machine images should be taken, in terms of operating efficiency, when you use a technique where you start up a server from a machine image, that is, when you use the Stamp Pattern.
In the Stamp Pattern, you can take the machine image after all set up (including middleware through applications) has been completed, with the middleware and applications started up and are running.While this lets you start up the virtual server extremely quickly, if you need to upgrade one of the middleware products, or you need to change a setting in an application, you will have to rebuild the machine image.
Explanation of the Cloud Solution/Pattern
AWS Cloud not only lets you create the machine image easily, but lets you set up the parameters at the time of start up. The use of this function lets you pass required parameters to the server configuration to have the server itself acquire the required settings when the server starts up, enabling you to create a machine image for executing installation, startup, and setup.This frees you from having to re-create the machine image each time there is a version update of an individual package.
Implementation
Put some thought into the creation of the Amazon Machine Image (AMI). Specifically, place the various parameter files required for initializing the EC2 instance (the virtual server) in Amazon Simple Storage Service (S3) (Internet storage), and then, when starting up an EC2 instance, have the EC2 instance read out the parameter files to build itself. You can place the parameter files in a repository such as Git.
Note that Amazon Linux has an initialization function known as cloud-init, enabling automatic execution through an initialization script that is written to the user data region.
- Prepare the data required for bootstrapping in S3 or another repository such as Git. Create an AMI that includes a bootstrap.
- Startup an EC2 instance from the specific AMI that includes the bootstrap.
- At the time of start up, the EC2 instance itself will acquire, install, startup, and setup the required packages.
- When necessary, dynamically replicate the servers based on the AMI.
Configuration
Benefits
- This eliminates the need for you to rebuild the AMI when there is a revision to a package that must be installed.
- Passing parameters, and the like, at the time of startup makes it easy for you to change dynamically the sequencing and details of set up at the time of startup.
Cautions
- You have a broad scope of choice when it comes to the layer for using a static AMI, and the layer above which to set up dynamically at the time of startup.
- When considering which pattern to apply, consider the trade-offs with the Stamp Pattern.