Chapter 2. Installing RHEL AI on AWS
There are 2 ways you can install and deploy Red Hat Enterprise Linux AI on AWS:
- You can purchase RHEL AI from the AWS marketplace.
-
You can download the RHEL AI
x86_64RAW file from the Download Red Hat Enterprise Linux AI page and convert it to an Amazon Machine Image (AMI), and install using the AMI.
2.1. Converting the RHEL AI RAW image to an AMI Copy linkLink copied to clipboard!
Before deploying RHEL AI on an AWS machine, you must set up an Amazon S3 bucket, convert the RHEL AI image to an Amazon Machine Image (AMI), and create the following resources:
- S3 bucket with the RHEL AI image
- AWS EC2 snapshot
- AWS AMI
- AWS instance
Prerequisites
- You have configured an access key ID in the AWS IAM account manager.
- You have installed the AWS CLI. For more information, see Installing or updating to the latest version of the AWS CLI.
Procedure
Create an S3 bucket and set the permissions to allow image file conversion to AWS snapshots.
Create the necessary environment variables. Open a shell prompt and run the following commands:
export BUCKET=<CUSTOM_BUCKET_NAME> export RAW_AMI=nvidia-bootc.ami export AMI_NAME="rhel-ai" export DEFAULT_VOLUME_SIZE=1000
$ export BUCKET=<CUSTOM_BUCKET_NAME> $ export RAW_AMI=nvidia-bootc.ami $ export AMI_NAME="rhel-ai" $ export DEFAULT_VOLUME_SIZE=1000Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the S3 bucket by running the following command:
aws s3 mb s3://$BUCKET
$ aws s3 mb s3://$BUCKETCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
trust-policy.jsonfile with the necessary configuration for generating an S3 role for your bucket:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the S3 role for your bucket. Run the following command:
aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json
$ aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
role-policy.jsonfile with the necessary configurations for generating a policy for your bucket:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the policy for your bucket by running the following command:
aws iam put-role-policy --role-name vmimport --policy-name vmimport-$BUCKET --policy-document file://role-policy.json
$ aws iam put-role-policy --role-name vmimport --policy-name vmimport-$BUCKET --policy-document file://role-policy.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Copy the
x86_64RAW image URL from the Download Red Hat Enterprise Linux AI page and download the image usingcurl:curl -Lo disk.raw.gz <RAW_IMAGE_URL>
$ curl -Lo disk.raw.gz <RAW_IMAGE_URL>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Unzip the
raw.gzfile:gunzip disk.raw.gz
$ gunzip disk.raw.gzCopy to Clipboard Copied! Toggle word wrap Toggle overflow Upload the image to the S3 bucket with the following command:
aws s3 cp disk.raw s3://$BUCKET/$RAW_AMI
$ aws s3 cp disk.raw s3://$BUCKET/$RAW_AMICopy to Clipboard Copied! Toggle word wrap Toggle overflow Convert the image to a snapshot and store it in the
TASK_IDvariable name by running the following commands:Copy to Clipboard Copied! Toggle word wrap Toggle overflow TASK_ID=$(aws ec2 import-snapshot --disk-container file://containers.json | jq -r .ImportTaskId)
$ TASK_ID=$(aws ec2 import-snapshot --disk-container file://containers.json | jq -r .ImportTaskId)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Follow the progress of the disk image to snapshot conversion job with the following command:
aws ec2 describe-import-snapshot-tasks --filters Name=task-state,Values=active
$ aws ec2 describe-import-snapshot-tasks --filters Name=task-state,Values=activeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get the snapshot ID and store it the
SNAPSHOT_IDvariable by running the following command:SNAPSHOT_ID=$(aws ec2 describe-import-snapshot-tasks | jq -r '.ImportSnapshotTasks[] | select(.ImportTaskId=="'${TASK_ID}'") | .SnapshotTaskDetail.SnapshotId')$ SNAPSHOT_ID=$(aws ec2 describe-import-snapshot-tasks | jq -r '.ImportSnapshotTasks[] | select(.ImportTaskId=="'${TASK_ID}'") | .SnapshotTaskDetail.SnapshotId')Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a tag name to the snapshot by running the following command:
aws ec2 create-tags --resources $SNAPSHOT_ID --tags Key=Name,Value="$AMI_NAME"
$ aws ec2 create-tags --resources $SNAPSHOT_ID --tags Key=Name,Value="$AMI_NAME"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Register the AMI from the snapshot with the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a tag name to identify the AMI by running the following command:
aws ec2 create-tags --resources $AMI_ID --tags Key=Name,Value="$AMI_NAME"
$ aws ec2 create-tags --resources $AMI_ID --tags Key=Name,Value="$AMI_NAME"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Deploying on AWS using the CLI Copy linkLink copied to clipboard!
You can launch the Red Hat Enterprise Linux AI AWS instance by using the RHEL AI Amazon Machine Image (AMI) from the AWS web console or by using the awscli CLI.
The following procedure describes how to use the awscli CLI to launch the AWS instance with the custom AMI.
Prerequisites
- You have created the RHEL AI AMI.
-
You have installed the awscli CLI, and configured it with your
aws_access_key_idandaws_secret_access_keyvariables. - You have configured your Virtual Private Cloud (VPC).
- You have created a subnet for your instance.
- You have created an SSH key pair.
- You have created an AWS security group on.
Procedure
Configure the various AWS parameters.
Set the
AMIvariable. Run the following command and copy the required AMI ID:aws ec2 describe-images --owners self
$ aws ec2 describe-images --owners selfCopy to Clipboard Copied! Toggle word wrap Toggle overflow AMI=<AMI_ID>
$ AMI=<AMI_ID>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
SECURITY_GROUPvariable. Run the following command and copy the required security group ID:aws ec2 describe-security-groups
$ aws ec2 describe-security-groupsCopy to Clipboard Copied! Toggle word wrap Toggle overflow SECURITY_GROUP=<SECURITY_GROUP_ID>
$ SECURITY_GROUP=<SECURITY_GROUP_ID>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
SUBNETvariable. Run the following command and copy the required subnet:aws ec2 describe-subnets
$ aws ec2 describe-subnetsCopy to Clipboard Copied! Toggle word wrap Toggle overflow SUBNET=<SUBNET>
$ SUBNET=<SUBNET>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
INSTANCE_TYPEvariable:INSTANCE_TYPE=<INSTANCE_TYPE_SIZE>
$ INSTANCE_TYPE=<INSTANCE_TYPE_SIZE>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
INSTANCE_NAMEvariable:INSTANCE_NAME=rhel-ai-instance
$ INSTANCE_NAME=rhel-ai-instanceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the disk size variable:
DISK_SIZE=<REQUIRED_DISK_SIZE>
$ DISK_SIZE=<REQUIRED_DISK_SIZE>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
KEY_NAMEvariable:KEY_NAME=<KEY_PAIR_NAME>
$ KEY_NAME=<KEY_PAIR_NAME>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Create the instance by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe default user account in the RHEL AI AMI is
cloud-user. Thecloud-useraccount has passwordlesssudoaccess.