Skip to content

Instantly share code, notes, and snippets.

@Cobra16319
Forked from jaredhocutt/rhcos-aws-upload.md
Created October 7, 2020 00:39
Show Gist options
  • Save Cobra16319/e36f9b818497c5809d9bc414aa35c779 to your computer and use it in GitHub Desktop.
Save Cobra16319/e36f9b818497c5809d9bc414aa35c779 to your computer and use it in GitHub Desktop.

RHCOS Image Upload to AWS

These instructions walk through how to upload a RHCOS image to AWS manually. If you are running in a public/commercial region of AWS, you should use the already provided RHCOS images available in those regions. However, if you are deploying into an alternative AWS region (e.g. GovCloud, C2S, etc.), then you will need to provide your own RHCOS image and these instructions will show you how to do that.

Note: This process only works with RHCOS 4.3+. This is due to there not being an image built for AWS in previous versions.

Download the AWS VMDK disk image, unarchive it, and upload it to S3:

wget http://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.3/latest/rhcos-43.81.201912030353.0-aws.x86_64.vmdk.gz

gunzip rhcos-43.81.201912030353.0-aws.x86_64.vmdk.gz

aws s3 cp rhcos-43.81.201912030353.0-aws.x86_64.vmdk s3://io-rdht-govcloud-vmimport

Create the disk containers file containers-43-aws-vmdk.json:

{
   "Description": "RHCOS 4.3 AWS VMDK",
   "Format": "vmdk",
   "UserBucket": {
      "S3Bucket": "io-rdht-govcloud-vmimport",
      "S3Key": "rhcos-43.81.201912030353.0-aws.x86_64.vmdk"
   }
}

Import the disk as a snapshot into AWS:

aws ec2 import-snapshot \
   --region us-gov-west-1 \
   --description "RHCOS 4.3 AWS VMDK" \
   --disk-container file://containers-43-aws-vmdk.json

Check the status of the image import:

aws ec2 describe-import-snapshot-tasks \
   --region us-gov-west-1

After the import is complete, you should see similar output:

{
    "ImportSnapshotTasks": [
        {
            "Description": "RHCOS 4.3 AWS VMDK",
            "ImportTaskId": "import-snap-fh6i8uil",
            "SnapshotTaskDetail": {
                "Description": "RHCOS 4.3 AWS VMDK",
                "DiskImageSize": 819056640.0,
                "Format": "VMDK",
                "SnapshotId": "snap-06331325870076318",
                "Status": "completed",
                "UserBucket": {
                    "S3Bucket": "io-rdht-govcloud-vmimport",
                    "S3Key": "rhcos-43.81.201912030353.0-aws.x86_64.vmdk"
                }
            }
        }
    ]
}

Register an image using the snapshot:

aws ec2 register-image \
   --region us-gov-west-1 \
   --architecture x86_64 \
   --description "RHCOS 4.3 AWS VMDK" \
   --ena-support \
   --name "RHCOS 4.3 AWS VMDK" \
   --virtualization-type hvm \
   --root-device-name '/dev/sda1' \
   --block-device-mappings 'DeviceName=/dev/sda1,Ebs={DeleteOnTermination=true,SnapshotId=snap-06331325870076318}'

You can now use this AMI for your RHCOS nodes when you deploy OpenShift 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment