Skip to content

Instantly share code, notes, and snippets.

@imjasonh
Created October 21, 2021 14:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imjasonh/c7a0f546226a69062a81abfee265c393 to your computer and use it in GitHub Desktop.
Save imjasonh/c7a0f546226a69062a81abfee265c393 to your computer and use it in GitHub Desktop.
Sketch/example pipeline to assemble a multi-arch manifest list based on arch-specific builds in a heterogeneous-arch cluster
# This Task runs a `docker build` on a specified node architecture.
# TODO:
# - mount source incl Dockerfile
# - mount a Docker daemon
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: build
spec:
params:
- name: arch
description: CPU architecture to build on
results:
- name: ref
podTemplate:
nodeSelector:
kubernetes.io/arch: $(params.arch)
steps:
- name: build
image: docker
script: |
docker build -t image:$(params.arch) .
cat image:$(params.arch) > $(results.ref.path)
---
# This Task combines N image references into a single manifest and pushes it.
# TODO: auth for the push
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: build-manifest
spec:
params:
- name: images
type: array
description: Images to combine into the manifest
- name: ref
description: Ref to give to the manifest
results:
- name: IMAGE_DIGEST
steps:
- name: build-manifest
image: docker
script: |
docker manifest create $(params.ref) $(params.images[*])
docker manifest push $(params.ref)
---
# This Pipeline runs N arch-specific builds, then combines their resulting
# images into a manifest list using the above tasks.
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: multiarch-build
spec:
tasks:
- name: build-amd64
taskRef:
name: build
params:
- name: arch
value: amd64
- name: build-arm64
taskRef:
name: build
params:
- name: arch
value: arm64
- name: build-ppc64le
taskRef:
name: build
params:
- name: arch
value: ppc64le
- name: build-s390x
taskRef:
name: build
params:
- name: arch
value: s390x
- name: build-manifest
taskRef:
name: build-manifest
params:
- name: images
value:
- $(tasks.build-amd64.ref)
- $(tasks.build-arm64.ref)
- $(tasks.build-ppc64le.ref)
- $(tasks.build-s390x.ref)
- name: ref
value: gcr.io/imjasonh/multiarch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment