Skip to content

Instantly share code, notes, and snippets.

@jaredhocutt
Last active June 28, 2021 17:23
Show Gist options
  • Save jaredhocutt/aae8aef663281ba2ebc943bdd009faa8 to your computer and use it in GitHub Desktop.
Save jaredhocutt/aae8aef663281ba2ebc943bdd009faa8 to your computer and use it in GitHub Desktop.

This gist is no longer maintained and may be incorrect. The latest version of this can be found at:

https://github.com/jaredhocutt/openshift4-guides/blob/master/docs/rhcos_ami_upload.md

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.

@mdutton3
Copy link

mdutton3 commented Nov 5, 2020

@brianredbeard, not all AWS regions are connected to the internet.

@jaredhocutt
Copy link
Author

Thanks for the details @brianredbeard. As @mdutton3 noted, these instructions are required in non-commercial AWS regions where there are not any RHCOS images (e.g. AWS GovCloud and other secret regions within AWS). These regions are also not connected to the commercial regions, so copying an AMI between regions does not work.

That said, this gist is old and not something I maintain anymore. I'll add a header to the top indicating as such. I've since made edits to the details and instructions, which can be found here: https://github.com/jaredhocutt/openshift4-guides/blob/master/docs/rhcos_ami_upload.md

In my own scripting, I also use the rhcos.json file to make it easy to download the RHCOS image, but this is unfortunately not a viable thing to use for documentation for our customers. They need to have this sort of data come from a validated Red Hat source, of which mirror.openshift.com is one, but a file in GitHub for the upstream code is not.

Therefore, when it comes to documenting the details, I specifically point to mirror.openshift.com.

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