Skip to main content
Skip table of contents

AWS: Create an Image

Learn how to build a custom AMI for use with DKP

AMI images contain configuration information and software to create a specific, pre-configured, operating environment. For example, you can create an AMI image of your current computer system settings and software. The AMI image can then be replicated and distributed, creating your computer system for other users. You can use overrides files to customize some of the components installed on your machine image. For example, you could tell KIB to install the FIPS versions of the Kubernetes components.

This procedure describes how to use the Konvoy Image Builder (KIB) to create a Cluster API compliant Amazon Machine Image (AMI). KIB uses variable overrides to specify base image and container images to use in your new AMI.

In previous DKP releases, AMI images provided by the upstream CAPA project would be used if you did not specify an AMI. However, the upstream images are not recommended for production and may not always be available.   Therefore, DKP now requires you to specify an AMI when creating a cluster. To create an AMI, use Konvoy Image Builder. Explore the Customize your Image topic for more options about overrides.

Prerequisites

Before you begin, you must:

Extract KIB Bundle if air-gapped

If not done previously during Konvoy Image Builder download in Prerequisites, extract the bundle and cd into the extracted konvoy-image-bundle-$VERSION folder. Otherwise, proceed to Build the Image.

In previous DKP releases, the distro package bundles were included in the downloaded air-gapped bundle. Currently, that air-gapped bundle contains the following artifacts with the exception of the distro packages:

  • DKP Kubernetes packages

  • Python packages (provided by upstream)

  • Containerd tarball

  1. Download dkp-air-gapped-bundle_v2.8.0_linux_amd64.tar.gz , and extract the tarball to a local directory:

    CODE
    tar -xzvf dkp-air-gapped-bundle_v2.8.0_linux_amd64.tar.gz && cd dkp-v2.8.0/kib
  2. You will need to fetch the distro packages as well as other artifacts. By fetching the distro packages from distro repositories, you get the latest security fixes available at machine image build time.

  3. In your download location, there is a bundles directory with all the steps to create an OS package bundle for a particular OS. To create it, run the new DKP command create-package-bundle. This builds an OS bundle using the Kubernetes version defined in ansible/group_vars/all/defaults.yaml. Example command:

    CODE
    ./konvoy-image create-package-bundle --os redhat-8.4 --output-directory=artifacts

    NOTE: For FIPS, pass the flag: --fips
    NOTE: For RHEL OS, pass your RedHat subscription manager credentials: export RMS_ACTIVATION_KEY. Example command:

    CODE
    export RHSM_ACTIVATION_KEY="-ci"
    export RHSM_ORG_ID="1232131"
  4. Follow the instructions below to build an AMI.

The konvoy-image binary and all supporting folders are also extracted. When run, konvoy-image bind mounts the current working directory (${PWD}) into the container to be used.

  • Set environment variables for AWS access. The following variables must be set using your credentials including required IAM:

    CODE
    export AWS_ACCESS_KEY_ID
    export AWS_SECRET_ACCESS_KEY
    export AWS_DEFAULT_REGION
  • If you have an override file to configure specific attributes of your AMI file, add it. Instructions for customizing an override file are found on this page: Image Overrides

Build the Image

Depending on which version of DKP you are running, steps and flags will be different. To deploy in a region where CAPI images are not provided, you need to use KIB to create your own image for the region. For a list of supported AWS regions, refer to the Published AMI information from AWS.

Begin image creation:

Run the konvoy-image command to build and validate the image.

CODE
konvoy-image build aws images/ami/rhel-86.yaml

By default, it builds in the us-west-2 region. to specify another region set the --region flag as shown in the command below:

CODE
konvoy-image build aws --region us-east-1 images/ami/rhel-86.yaml

Ensure you have named the correct AMI image YAML file for your OS in the konvoy-image build command.

After KIB provisions the image successfully, the ami id is printed and written to the packer.pkr.hcl (Packer config) file. This file has an artifact_id field whose value provides the name of the AMI ID as shown in the example below. That is the ami you use in the dkp create cluster command:

CODE
{
  "builds": [
    {
      "name": "kib_image",
      "builder_type": "amazon-ebs",
      "build_time": 1698086886,
      "files": null,
      "artifact_id": "us-west-2:ami-04b8dfef8bd33a016",
      "packer_run_uuid": "80f8296c-e975-d394-45f9-49ef2ccc6e05",
      "custom_data": {
        "containerd_version": "",
        "distribution": "RHEL",
        "distribution_version": "8.6",
        "kubernetes_cni_version": "",
        "kubernetes_version": "1.26.6"
      }
    }
  ],
  "last_run_uuid": "80f8296c-e975-d394-45f9-49ef2ccc6e05"
}

To use a custom AMI when creating your cluster, you must create that AMI using KIB first. Then perform the export and name the custom AMI for use in the command dkp create cluster:

CODE
export AWS_AMI_ID=ami-<ami-id-here>

Inside the sections for either Non-air-gapped or Air-gapped cluster creation, you will find the instructions for how to apply custom images.

Related Information:

  • To use a local registry even in a non-air-gapped environment, download and extract the bundle. Download the Complete DKP Air-gapped Bundle for this release (i.e. dkp-air-gapped-bundle_v2.7.0_linux_amd64.tar.gz) to load registry.

  • Load the Registry

Next Step:

AWS: Create the Management Cluster

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.