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
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.
FYI:
Is incorrect. While builds may not have been published to
mirrors.openshift.com
builds of RHCOS have been available since the release of OpenShift v4.Additionally, it would be faster to pull the existing public AMI images. The canonical location of metadata about RHCOS releases is within the OpenShift installer and can be retrieved from here: https://github.com/openshift/installer/blob/master/data/data/rhcos.json
Thus, your example above pivots to using copy-image:
Keep in mind though that this now means that resource/catalog management over time is now the burden of the user which inevitably leads to questions like "is this image being used? is it safe to delete?" which occur long after you've stopped talking to the customer.
In general though, it would be better to just use the
boto3
libraries and Python 3 to make short work of this. For example, this is the script I've been using in my own local CI for bare metal testing.That being said..... I couldn't help myself a just went ahead a wrote the tool: https://gist.github.com/brianredbeard/689ee4e8efc72c739b22ac525d756c50
Also, just to prove I'm not bullshitting you: https://github.com/openshift/installer/blob/release-4.0/data/data/rhcos.json