Skip to main content

Creating Image Templates

An image template is the blueprint for your golden images. It defines the base operating system, the software components to install, the security hardenings to apply, and the distribution targets. This guide walks you through the process of creating a template.

Prerequisites

Before you create a template, ensure you have met the following requirements:

  1. A valid customer account in Klarity ImageFactory.
  2. At least one onboarded cloud account with a status of ACCESS_SUCCESS.
  3. A clear understanding of the software and security requirements for your image.

Template Creation Flow

The process of defining a template involves several logical steps. You can perform these through the ImageFactory console or via the API.

1. Choose a Provider

Select the cloud provider where the image will be built and distributed. ImageFactory supports AWS, Azure, GCP, Exoscale, IBM Cloud, and VMware.

2. Select a Distribution

A distribution represents a specific version of an operating system (e.g., Ubuntu 22.04, Windows Server 2022). The distribution must be compatible with your chosen provider.

3. Configure Build Components

Build components are scripts or configurations that run during the image creation process. These can include:

  • Software installations (e.g., Docker, Java, monitoring agents).
  • System configurations (e.g., timezone, proxy settings).
  • Security hardenings (e.g., CIS benchmarks, custom scripts).

4. Configure Test Components

Test components are executed after the build process to verify the image's integrity and compliance. These can include:

  • Functional tests (e.g., checking if a service is running).
  • Security scans (e.g., vulnerability assessments).
  • Compliance scoring.

5. Set Provider-Specific Configuration

Each provider requires specific settings, such as:

  • AWS: Region, instance type, and KMS key ID.
  • Azure: Resource group, storage account, and gallery details.
  • GCP: Project ID and zone.

6. Optional Settings

You can further customize your template with these optional settings:

  • Tags: Key-value pairs for resource organization.
  • Notifications: Configure alerts for build success or failure.
  • Cyclical Rebuilds: Enable automatic rebuilds based on security updates or source image changes.
  • Image Retention: Define how many versions of the image to keep in your cloud account.

Validation Rules

ImageFactory enforces several rules to ensure your template is valid:

  • Compatibility: The selected distribution must match the provider.
  • Component Support: All selected components must support the OS family and the provider.
  • Unique Name: Each template must have a unique name within your customer account.
  • Limits: There are limits on the number of templates you can create per provider and OS family.

Automatic Build Trigger

Once you successfully create a template, ImageFactory automatically triggers the first build. You can monitor the progress of this build in the "Images" section of the console.

For a detailed walkthrough of the template creation wizard, see the Creating a Template guide.

Via API

You can also create templates programmatically using the GraphQL API:

mutation CreateTemplate {
createTemplate(input: {
name: "Ubuntu-22.04-Production"
provider: AWS
distributionId: "ubuntu-22.04-lts"
buildComponents: [
{ id: "install-docker", version: "1.0.0" }
{ id: "apply-cis-hardening", version: "2.1.0" }
]
testComponents: [
{ id: "verify-docker-service" }
]
awsConfig: {
region: "eu-central-1"
instanceType: "t3.medium"
}
imageRetainCount: 5
disableCyclicalRebuilds: false
}) {
id
status
}
}

By following this structured approach, you can ensure that your golden images are consistent, secure, and ready for deployment across your multi-cloud environment.