Build Cross-Platform Images with Buildah and Merge-Image
TOC
Feature OverviewUse CasesPrerequisitesStep 1: Prepare Registry CredentialsStep 2: Create Pipeline and Run PipelineRunStep 3: Verify Merged Image PlatformsTroubleshootingRelatedFeature Overview
This guide shows how to build per-architecture images with the buildah Task, then merge them into a single multi-architecture image with the merge-image Task.
Typical flow:
- Build
linux/amd64image tag (for example:v1.0.0-amd64) - Build
linux/arm64image tag (for example:v1.0.0-arm64) - Merge source tags into one or more target tags (for example
:v1.0.0,:latest)
Use Cases
- Build and publish multi-architecture images from one code repository.
- Keep architecture-specific build outputs while exposing one unified release tag.
- Re-tag and publish multiple target tags in one merge step.
Prerequisites
Tekton Pipelinesis installed.git-clone,buildah(0.9), andmerge-image(0.1)Tasksare installed.- You can push images to your registry.
- Registry credentials are prepared as a Kubernetes
Secret. - If you use native node-based builds (as shown in this guide), your cluster must have both
amd64andarm64nodes available. - Optional local verification tools:
crane,jq.
Step 1: Prepare Registry Credentials
Create a generic secret with config.json:
Step 2: Create Pipeline and Run PipelineRun
Update the following values before use:
- Git repository URL and revision
- Architecture-specific source image tags and final target image tag
- Crane runtime image, if you need to replace the default
- Workspace and secret names
Example Pipeline:
Example PipelineRun:
Key points in this example:
- The example uses hub resolver references for
git-clone,buildah, andmerge-image, so the corresponding catalog Tasks must be resolvable in your cluster. image-amd64andimage-arm64are explicit Pipeline parameters. This keeps the merge input unambiguous and matches howmerge-imageconsumessourceImages.taskRunSpecs+podTemplate.nodeSelectorare configured in thePipelineRunand are critical when your cluster has mixed CPU architectures. They make sure each build task runs on the matching node architecture.- By default, Tekton uses
coschedule: workspaces, which creates an Affinity Assistant and tries to place TaskRuns sharing the same PVC-backed workspace on the same node. If you pinbuildah-amd64andbuildah-arm64to different architectures, this default behavior conflicts with the per-tasknodeSelector. In that case, setspec.pipeline.coschedule: disabledin yourTektonConfigso Tekton stops forcing shared-workspace TaskRuns onto one node. The operator will propagate that setting to thefeature-flagsConfigMap automatically. - Disabling
coscheduleis necessary for cross-architecture scheduling, but it is not sufficient on its own. If the shared workspace is backed by aReadWriteOncePVC, Kubernetes still cannot mount that volume read-write on two different nodes at the same time. To run the amd64 and arm64 builds concurrently on different nodes, use a workspace backend that supports multi-node sharing such asReadWriteMany. sourceImagesshould point to the architecture-specific tags, whiletargetImagesshould be the final multi-arch tag or tags you want to publish.registry-credentialsworkspace is reused by bothbuildahandmerge-image; the workspace name mapping (registryconfigvsregistry-config) is task-interface specific and must match each Task definition.
Step 3: Verify Merged Image Platforms
After PipelineRun succeeds, you can verify the merged image platforms with crane, podman, or skopeo:
Using crane:
Using podman:
Using skopeo:
Expected output includes:
linux/amd64linux/arm64
Troubleshooting
- If
buildah-amd64andbuildah-arm64share one PVC-backed workspace and are pinned to different architectures, check the Tekton Pipelines feature flagcoschedule. Setspec.pipeline.coschedule: disabledin yourTektonConfigwhen you need those TaskRuns to schedule onto different nodes; the defaultworkspacesmode tries to co-locate them on one node through Affinity Assistant. For the exact setting location and behavior, see Unable to Use Multiple PVC Workspaces in Tekton. - Even with
coschedule: disabled, aReadWriteOncePVC still cannot be mounted read-write from two different nodes simultaneously. For true parallel cross-architecture builds, bind the shared workspace to storage that supportsReadWriteMany. - Prefer keeping
sourceImagesandtargetImagesin the same registry. Cross-registry input is allowed butmerge-imageemits warning logs. merge-imageallows cross-repository merges. For cross-registry source or target images, it continues with warning logs, so make sure credentials are valid for every registry involved.sourceImagesandtargetImagesmust be non-empty. Duplicate source references or duplicate source digests are skipped, and at least one unique source image must remain.- For self-signed registries:
buildah: mount CA files tosslcertdirmerge-image: mount CA files toca-bundleand optionally setcaFileName- set
TLS_VERIFY/tlsVerifytofalseonly in trusted environments
buildahparameters are uppercase (for exampleIMAGES,CONTAINERFILE), whilemerge-imageuses lower camel case (for examplesourceImages,targetImages).