Learn how to build a custom AMI for use with DKP

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.

The default AWS image is not recommended for use in production. We suggest using Konvoy Image Builder to create a custom AMI to take advantage of enhanced cluster operations. Explore the KIB with AWS topics for more options.

Prerequisites

Before you begin, you must:

Extract KIB Bundle

Extract the bundle and cd into the extracted konvoy-image-bundle-$VERSION folder. The bundled version of konvoy-image contains an embedded docker image that contains all the requirements for building.

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:

    export AWS_ACCESS_KEY_ID
    export AWS_SECRET_ACCESS_KEY
    export AWS_DEFAULT_REGION
    CODE
  • If you have an override file to configure specific attributes of your AMI file, add it.

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.

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.

Execute the following to begin image creation:

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

konvoy-image build aws images/ami/centos-79.yaml
CODE

By default it builds in the us-west-2 region. to specify another region set the --region flag:

konvoy-image build aws --region us-east-1 images/ami/centos-79.yaml
CODE

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

Once KIB provisions the image successfully, the ami id is printed and written to the manifest.json file. This file has an artifact_id field whose value provides the name of the AMI ID as shown in the example below:

{
      "name": "rhel-7.9-fips",
      "builder_type": "amazon-ebs",
      "build_time": 1659486130,
      "files": null,
      "artifact_id": "us-west-2:ami-0f2ef742482e1b829",
      "packer_run_uuid": "0ca500d9-a5f0-815c-6f12-aceb4d46645b",
      "custom_data": {
        "containerd_version": "",
        "distribution": "RHEL",
        "distribution_version": "7.9",
        "kubernetes_cni_version": "",
        "kubernetes_version": "1.24.5+fips.0"
      }
    }
CODE

Related Information

For information on related topics or procedures, refer to the following: