Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 3. Installing RHEL AI on AWS
There are multiple 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 RAW file on the RHEL AI download page and convert it to an AWS image.
For installing and deploying RHEL AI using the RAW file, you must first convert the RHEL AI image into an Amazon Machine Image (AMI).
3.1. Converting the RHEL AI image to an AWS AMI Copier lienLien copié sur presse-papiers!
Before deploying RHEL AI on an AWS machine, you must set up a S3 bucket and convert the RHEL AI image to a AWS AMI.
In the following process, you create the following resources:
- An S3 bucket with the RHEL AI image
- AWS EC2 snapshots
- An AWS AMI
- An AWS instance
Prerequisites
- You have an Access Key ID configured in the AWS IAM account manager.
Procedure
- Install the AWS command-line tool by following the AWS documentation
You need to create a S3 bucket and set the permissions to allow image file conversion to AWS snapshots.
Create the necessary environment variables by running 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=1000
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteOn AWS, the
DEFAULT_VOLUME_SIZE
is measured GBs.You can create an S3 bucket by running the following command:
aws s3 mb s3://$BUCKET
$ aws s3 mb s3://$BUCKET
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must create a
trust-policy.json
file with the necessary configurations for generating a S3 role for your bucket:printf '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "vmie.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals":{ "sts:Externalid": "vmimport" } } } ] }' > trust-policy.json
$ printf '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "vmie.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals":{ "sts:Externalid": "vmimport" } } } ] }' > trust-policy.json
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an S3 role for your bucket that you can name. In the following example command,
vmiport
is the name of the role.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.json
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must create a
role-policy.json
file with the necessary configurations for generating a policy for your bucket:printf '{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket" ], "Resource":[ "arn:aws:s3:::%s", "arn:aws:s3:::%s/*" ] }, { "Effect":"Allow", "Action":[ "ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe*" ], "Resource":"*" } ] }' $BUCKET $BUCKET > role-policy.json
$ printf '{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket" ], "Resource":[ "arn:aws:s3:::%s", "arn:aws:s3:::%s/*" ] }, { "Effect":"Allow", "Action":[ "ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe*" ], "Resource":"*" } ] }' $BUCKET $BUCKET > role-policy.json
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a 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.json
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Now that your S3 bucket is set up, you need to download the RAW image from Red Hat Enterprise Linux AI download page
Copy the RAW image link and add it to the following command:
curl -Lo disk.raw.gz <link-to-raw-file>
$ curl -Lo disk.raw.gz <link-to-raw-file>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Unzip the
raw.gz
file with the following command:gunzip disk.raw.gz
$ gunzip disk.raw.gz
Copy 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_AMI
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Convert the image to a snapshot and store it in the
task_id
variable name by running the following commands:printf '{ "Description": "my-image", "Format": "raw", "UserBucket": { "S3Bucket": "%s", "S3Key": "%s" } }' $BUCKET $RAW_AMI > containers.json
$ printf '{ "Description": "my-image", "Format": "raw", "UserBucket": { "S3Bucket": "%s", "S3Key": "%s" } }' $BUCKET $RAW_AMI > containers.json
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 You can check 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=active
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Once the conversion job is complete, you can get the snapshot ID and store it in a variable called
snapshot_id
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, so it’s easier to identify, 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 an AMI from the snapshot with the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can add another 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
3.2. Deploying your instance on AWS using the CLI Copier lienLien copié sur presse-papiers!
You can launch the AWS instance with your new RHEL AI AMI from the AWS web console or the CLI. You can use whichever method of deployment you want to launch your instance. The following procedure displays how you can use the CLI to launch your AWS instance with the custom AMI.
If you choose to use the CLI as a deployment option, there are several configurations you have to create, as shown in "Prerequisites".
Prerequisites
- You created your RHEL AI AMI. For more information, see "Converting the RHEL AI image to an AWS AMI".
- You have the AWS command-line tool installed and is properly configured with your aws_access_key_id and aws_secret_access_key.
- You configured your Virtual Private Cloud (VPC).
- You created a subnet for your instance.
- You created a SSH key-pair.
- You created a security group on AWS.
Procedure
For various parameters, you need to gather the ID of the variable.
To access the image ID, run the following command:
aws ec2 describe-images --owners self
$ aws ec2 describe-images --owners self
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To access the security group ID, run the following command:
aws ec2 describe-security-groups
$ aws ec2 describe-security-groups
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To access the subnet ID, run the following command:
aws ec2 describe-subnets
$ aws ec2 describe-subnets
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Populate environment variables for when you create the instance
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create your instance using the variables by running the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
User account
The default user account in the RHEL AI AMI is cloud-user
. It has all permissions via sudo
without password.
Verification
To verify that your Red Hat Enterprise Linux AI tools are installed correctly, you need to run the
ilab
command:ilab
$ ilab
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Updating Red Hat Enterprise Linux AI
To update to the latest z-stream version of RHEL AI, follow the procedures in the Updating Red Hat Enterprise Linux AI documentation.