Build AWS Cloud Images
In this guide, you will use the CanvOS utility to build provider images that enable deploying Edge clusters on
Amazon Elastic Compute Cloud (Amazon EC2). The aws-cloud-image target takes a CanvOS
raw disk image and imports it into Amazon Web Services (AWS), creating and registering an Amazon Machine Image (AMI)
that you can use to launch EC2 instances. This target automates the workflow from raw image creation through AMI
registration in AWS.
Prerequisites
-
A physical or virtual Linux machine with AMD64 (also known as x86_64) processor architecture to build the Edge artifacts. You can issue the following command in the terminal to check your processor architecture.
uname -m -
Minimum hardware configuration of the Linux machine:
- 4 CPU
- 8 GB memory
- 150 GB storage
-
Git. You can ensure git installation by issuing the
git --versioncommand. -
(Optional) Earthly is installed and available. If you do not install Earthly, you can still build the artifacts, but it would require root privileges, and some of the resulting artifacts will be owned by the root user.
-
An image management tool such as Docker or crane is installed and available.
infoIf you do not install Earthly, you must install Docker.
-
An Amazon S3 bucket for image storage and the credentials to access it. Refer to the Getting started with Amazon S3 guide for further information on S3 usage. Your AWS credentials must have the following permissions:
s3:PutObjects3:GetObjects3:ListBucketec2:ImportSnapshotec2:DescribeImportSnapshotTasksec2:DescribeSnapshotsec2:RegisterImageec2:DescribeImagesec2:CreateTags
Build AWS Cloud Images
-
Check out the CanvOS GitHub repository containing the starter code.
git clone https://github.com/spectrocloud/CanvOS.git -
Change to the
CanvOSdirectory.cd CanvOS -
View the available git tag.
git tag -
Check out the newest available tag. This guide uses the tag v4.8.5 as an example.
git checkout v4.8.5 -
Review the files relevant for this guide.
-
.arg.template- A sample.argfile that defines arguments to use during the build process. -
Earthfile- Contains a series of commands to create target artifacts. -
earthly.sh- Script to invoke the Earthfile and generate target artifacts.
-
-
Issue the command below to assign an image tag value that will be used when creating the provider images. This guide uses the value
palette-learnas an example. However, you can assign any lowercase and alphanumeric string to theCUSTOM_TAGargument.export CUSTOM_TAG=palette-learn -
Use the command below to save the image registry hostname in the
IMAGE_REGISTRYargument. Before you execute the command, replace[REGISTRY-HOSTNAME]in the declaration below with your Docker ID. Your image registry hostname must comply with standard Domain Name System (DNS) rules and may not contain underscores.export IMAGE_REGISTRY=[REGISTRY-HOSTNAME] -
Issue the following command to use the Ubuntu OS distribution and use the 24.04 version.
export OS_DISTRIBUTION=ubuntu
export OS_VERSION=24.04 -
Issue the following command to use the Palette eXtended Kubernetes - Edge (PXK-E) Kubernetes distribution and use the 1.33.5 version.
export K8S_DISTRIBUTION=kubeadm
export K8S_VERSION=1.33.5 -
Use the command below to save the image S3 bucket region in the
REGIONargument and the S3 bucket name in theS3_BUCKETargument. Before you execute the command, replace[S3-BUCKET-REGION]with your bucket region and[S3-BUCKET-NAME]with your bucket name.export REGION=[S3-BUCKET-REGION]
export S3_BUCKET=[S3-BUCKET-NAME] -
Optionally, you can set an S3 object key for your image. Replace the
[IMAGE-KEY]with a custom image key and execute the command. If you do not set a key, the image tag you set in Step 6 will be used.export S3_KEY=[IMAGE-KEY] -
Use the command below to save your AWS access key in the
AWS_ACCESS_KEY_IDargument and the AWS secret access key in theAWS_SECRET_ACCESS_KEYargument. Before you execute the command, replace[ACCESS-KEY]with your access key and[SECRET_ACCESS_KEY]with your secret access key.export AWS_ACCESS_KEY_ID=[ACCESS-KEY]
export AWS_SECRET_ACCESS_KEY=[SECRET_ACCESS_KEY] -
Issue the command below to create an
.argfile. The.argfile uses the default values for the remaining arguments.cat << EOF > .arg
IMAGE_REGISTRY=$IMAGE_REGISTRY
OS_DISTRIBUTION=$OS_DISTRIBUTION
OS_VERSION=$OS_VERSION
IMAGE_REPO=$OS_DISTRIBUTION
CUSTOM_TAG=$CUSTOM_TAG
K8S_DISTRIBUTION=$K8S_DISTRIBUTION
K8S_VERSION=$K8S_VERSION
ARCH=amd64
HTTPS_PROXY=
HTTP_PROXY=
PROXY_CERT_PATH=
UPDATE_KERNEL=false
REGION=$REGION
S3_BUCKET=$S3_BUCKET
S3_KEY=$S3_KEY
EOFRefer to Edge Artifact Build Configurations for all available configuration parameters.
-
(Optional) If you want to build multiple versions of provider images using different Kubernetes versions, remove the
K8S_VERSIONargument from the.argfile. Open thek8s_version.jsonfile in theCanvOSdirectory. Remove the Kubernetes versions that you do not need from the JSON object corresponding to your Kubernetes distribution. -
Issue the command below to create a
.secretfile containing your AWS credentials.cat << EOF > .secret
AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
EOF -
CanvOS utility uses Earthly to build the target artifacts. Issue the following command to start the build process.
./earthly.sh +aws-cloud-image --ARCH=amd64# Output condensed for readability
===================== Earthly Build SUCCESS =====================
Share your logs with an Earthly account (experimental)! Register for one at https://ci.earthly.dev.
Validate
-
Sign in to the AWS Management Console.
-
Navigate to Amazon S3.
-
Open the bucket you configured in Step 10.
-
Verify that the provider image file appears in the object list.