Skip to main content
Skip table of contents

Create a custom AMI

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). 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. The KIB uses variable overrides to specify base image and container images to use in your new AMI.

Prerequisites

Before you begin, you must:

  • Download the supported version of the KIB bundle (prefixed with konvoy-image-bundle) for your OS. Do not use the release prefixed with konvoy-image-builder.

  • Create a working Docker setup.

Extract AMI Bundle

Extract the bundle and cd into the extracted konvoy-image-bundle-$VERSION_$OS 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:

    CODE
    export AWS_ACCESS_KEY_ID
    export AWS_SECRET_ACCESS_KEY
    export AWS_DEFAULT_REGION
  • Ensure you have an override file to configure specific attributes of your AMI file.

Build the image

Depending on which version of DKP you are running, steps and flags will be different.

Do the following:

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

CODE
konvoy-image build images/ami/centos-7.yaml

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

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

When the command is complete the ami id is printed and written to ./manifest.json.

Launch a DKP cluster with a custom AMI

To use the built ami with DKP, specify it with the --ami flag when calling cluster create.

CODE
dkp create cluster aws --cluster-name=$(whoami)-aws-cluster --ami ami-0123456789

Launch a DKP cluster with custom AMI lookup

By default konvoy-image will name the AMI in such a way that dkp can discover the latest AMI for a base OS and Kubernetes version. To create a cluster that will use the latest AMI, specify the --ami-format, --ami-base-os and --ami-owner flags:

CODE
dkp create cluster aws --cluster-name=$(whoami)-aws-cluster --ami-format "konvoy-ami-{{.BaseOS}}-?{{.K8sVersion}}-*" --ami-base-os centos-7 --ami-owner 123456789012

Related information

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

JavaScript errors detected

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

If this problem persists, please contact our support.