Creating a custom image for compute nodes
The custom image builder tool enables the creation of pre-optimized images for compute nodes with IBM Spectrum LSF and essential open-source packages. If additional need to customize or install any third-party packages, use this tool to build private custom images tailored for your Spectrum LSF deployment. This automated solution starts with an IBM Cloud base image (stock image) and installs essential IBM Spectrum LSF components along with any prerequiste packages for the LSF images to work as defined and validates the final image. These custom images can be version-controlled and accessed through your private image catalog, providing flexibility and efficiency for maintaining and updating compute environments.
Features
The custom image builder is a tool that guides you through creating customized images for your IBM® Spectrum LSF environment, by using an automated process. Key features of the custom image builder include:
- Tailored for your HPC environment
- The custom image builder creates tailored images specifically for HPC environments by using an automated process. The automation helps ensure that images are optimized for workload management and performance. It handles software configuration and dependencies that are necessary to effectively manage compute nodes within the cluster.
- Automated image creation
- The custom image builder automatically builds and configures images by using Packer. This automation reduces manual intervention and helps ensure consistency across image deployments.
- Support for multiple operating systems
- The custom image builder supports images for RHEL and Rocky Linux®, which provides flexibility for different HPC environments and software requirements.
- Script-driven customization
- To customize your images, you edit a user-provided script (
customer_script.sh
) and specify software packages, dependencies, and configurations specific to your business needs. - IBM® Spectrum LSF deployment validation
- After the custom image builder creates the image, the automation validates it through IBM® Spectrum LSF deployment, which helps ensure that the image is functional and ready for use within the cluster.
- Private catalog integration
- You can add the created custom image to your private catalog within your IBM Cloud account to maintain a version history of the images created.
Prerequisites
Before you use the custom image builder, you require prerequisites to be installed in the location (local host or a VSI) where you want to run the custom image deployment:
-
Git: The necessary files and scripts for the custom image builder are available in a Git repository that you clone to your local directory. Make sure that you have Git for your platform.
First, create a directory where you will clone the Git repository (for example, one called
mydirectory
):cd <my-directory>
Then, clone the repository by running:
git clone https://github.com/terraform-ibm-modules/terraform-ibm-hpc/tree/main/tools/image-builder
-
Terraform: The custom image builder requires Terraform, as you run Terraform commands to build your custom image with the tool. Make sure that you have Terraform 1.9.0 or later installed.
To determine the Terraform version installed, run:
terraform --version
If Terraform is not installed or if it requires updating, refer to the Terraform site for details.
For Terraform installation information, see the Terraform documentation.
Preinstalled software packages with the custom image builder
Along with Terraform, the custom image builder uses and installs the following software:
Setting up your infrastructure
The custom image builder uses a deployable architecture that helps ensure correctly established network, compute, and security configurations. This way, IBM® Spectrum LSF deployment is seamless and scalable. You can either provide existing infrastructure resources, or allow the model to dynamically create new ones, including essential infrastructure such as VPCs, VSIs, and security groups.
All custom image builder values are set in a customer_script.sh
script, which you clone from the custom image builder Git repository.
Clone the repository to a platform from which you run the custom image builder. You can deploy from a local host or a VSI. After you clone, switch to the tools/image-builder
directory.
You can provide existing values or leave them null so that the custom image builder automatically creates the values for you.
For example:
-
You can provide an existing VPC, subnets, and security group. Otherwise, the automation creates new ones. For example, specify an existing VPC name for the
vpc_name
variable and the existing subnet IDs for thesubnet_id
variable. Otherwise, if thevpc_name
value is set to null, the automation creates a new VPC, along with the subnets. -
You can provide an existing security group ID for the
security_group_id
variable, or you can leave it null so that the automation created an ID for you. -
You can provide an existing key management service (KMS) instance and key for start volume encryption for VSI-1:
- For the
key_management
variable, specify the type of encryption you want to use. To use provider-managed encryption instead of IBM Key Protect, set thekey_management
value to null. - For the
key_instance_name
variable, specify the name of the existing IBM Key Protect instance to be used for boot volume encryption for VSI-1. - For the
kms_key_name
variable, specify the name of the existing KMS encryption key to be used for boot volume encryption for VSI-1.
- For the
If these KMS values are not provided, the automation creates a new KMS instance and key.
Enabling a VPN
A VPN helps connect your on-premises network to the IBM Cloud VPC network, which enables secure communication between the two environments.
The custom image automation supports creating a VPN gateway if you set the enable_vpn
value as true (by default, it is set to false). After the automation creates the VPN gateway, you need to create VPN connections, and any other
security group rule changes as necessary, under that VPN gateway. See the IBM Cloud VPC documentation for details on adding connections to a VPN gateway.
If you are enabling a VPN, you do not require creating floating IP addresses. For example, if you enabled a VPN, to connect to VSI-1 without a floating IP address, run:
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@${packer_vsi_1_private_ip}
By default, a floating IP is created and attached to VSI-1. If you do not require a floating IP, then set the enable_fip
value to false.
Creating a custom image
Custom image builder workflow
With the custom image builder, you can write your own scripts to install extra packages (including open source packages, dependencies, and configuration requirements) for RHEL and Rocky Linux® images, along with the essential packages installed.
Use the provided customer_script.sh
script as a template for your script. Provide values based on the operating system you choose for the source_image_name
variable. Whenever a new dynamic node joins the cluster,
all additional packages and necessary configuration are automatically included for the new nodes.
The custom image automation creates two VSIs: VSI-1 is a bootstrap node VSI, and VSI-2 is a worker node VSI.
The overall flow for creating your custom image by using the custom image builder is as follows:
-
With the bootstrap node VSI created, the automation installs the necessary version of open source Packer.
-
After Packer is installed, the automation triggers a new VSI for image-building purposes. Based on the value you provide for the
source_image_name
variable, the automation starts the worker node VSI and uses it to create the RHEL or Rocky Linux® custom image based on your specifications, calling two scripts:- To include the LSF prerequisites in the custom image, the automation calls a
script.sh
script to install the appropriate LSF packages. To view installation logs on the bootstrap node, refer to thevar/log/cloud-init-output.log
file. - To include any additional open source packages in the custom image, the automation calls your
customer_script.sh
script with your predefined cusotmizations, after thescript.sh
script.
When the installation completes, VSI-2 moves to stopped state and the image creation process begins.
- To include the LSF prerequisites in the custom image, the automation calls a
-
After the worker node VSI creates the image, the automation helps ensure that the image is set to an available state. The automation then initiates IBM® Spectrum LSF deployment by using the new image to validate the deployment process, helping ensure that the new image is correct and can deploy successfully.
The IBM® Spectrum LSF deployment requests the
cluster_id
and IBM user number deployment input values, as they are necessary to validate the IBM® Spectrum LSF deployment from the newly created custom image. -
(Optional): The custom image builder also requires the
private_catalog_id
where the new image is added, published, and then shared with other necessary accounts. If you do not provide a catalog ID, then the image is created and validated.
Running the custom image builder
To create your custom image with the custom image builder, you edit a variables.tf
file, and then run Terraform commands.
Make sure that Terraform is installed as outlined in the prerequisites.
To create your custom image:
-
Go to the project directory where you cloned the custom image builder repository. For example:
cd <mydirectory>/tools/image-builder
-
Edit the
variables.tf
file with input parameters and values. -
Run the image builder commands:
terraform init terraform plan terraform apply
Apply complete! Resources: 36 added, 0 changed, 0 destroyed.
Outputs:
packer_vsi_name = "test-lsf-packer-ccf4-001" ssh_to_packer_vsi = "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@165.192.133.183" subnet_id = "02g7-fc720c96-ec50-43d2-919a-e33b4566ccf4" vpc_id = "r022-016dbd43-fec6-4a81-9e85-c5d1cfe03ee5"
-
Use validation logs to see the status and troubleshoot any issues:
- For Packer logs and script execution logs for the custom image builder, log in to VSI-1 (the bootstrap node) and check the
/var/log/cloud-init-output.log
user data log. - For IBM® Spectrum LSF deployment with the new custom image, access the full run log from VSI-1 at
<mydirectory>/terraform-ibm-hpc-tools/tests/<log_file_name_with_date>
. - For IBM® Spectrum LSF deployment validation, dynamic node creation, and catalog validation, view the log files from VSI-1 at
<mydirectory>/terraform-ibm-hpc-tools/tests/test_output/log_*.log
.