From e327ed8d6dd938e090263970da13e067172424ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Wed, 24 Apr 2024 11:30:51 +0200 Subject: [PATCH] new example pipeline --- examples/htop/tekton/pipeline.yaml | 3 - examples/quarkus/tekton/pipeline.yaml | 132 +++++++++++++++++++++++ examples/quarkus/tekton/pipelinerun.yaml | 59 ++++++++++ tekton/task-buildah-build.yaml | 7 +- tekton/task-buildah-push.yaml | 2 +- 5 files changed, 197 insertions(+), 6 deletions(-) create mode 100644 examples/quarkus/tekton/pipeline.yaml create mode 100644 examples/quarkus/tekton/pipelinerun.yaml diff --git a/examples/htop/tekton/pipeline.yaml b/examples/htop/tekton/pipeline.yaml index 09fdcdd..a7b3472 100644 --- a/examples/htop/tekton/pipeline.yaml +++ b/examples/htop/tekton/pipeline.yaml @@ -14,9 +14,6 @@ spec: type: string - name: image-name type: string - - name: manifest-name - type: string - default: "tekton" - name: context-dir type: string default: "." diff --git a/examples/quarkus/tekton/pipeline.yaml b/examples/quarkus/tekton/pipeline.yaml new file mode 100644 index 0000000..1b85224 --- /dev/null +++ b/examples/quarkus/tekton/pipeline.yaml @@ -0,0 +1,132 @@ +apiVersion: tekton.dev/v1beta1 +kind: Pipeline +metadata: + name: quarkus-getting-started +spec: + + workspaces: + - name: sources + - name: oci-images + - name: registry-token + - name: maven-settings + + params: + - name: git-url + type: string + - name: image-name + type: string + - name: context-dir + type: string + default: "." + - name: containerfile-path + type: string + default: "Containerfile" + + tasks: + + - name: clone-repo-x86-64 + taskRef: + kind: ClusterTask + name: git-clone + params: + - name: url + value: $(params.git-url) + - name: revision + value: "main" + workspaces: + - name: output + workspace: sources + subPath: src-x86_64 + + - name: clone-repo-aarch64 + taskRef: + kind: ClusterTask + name: git-clone + params: + - name: url + value: $(params.git-url) + - name: revision + value: "main" + workspaces: + - name: output + workspace: sources + subPath: src-aarch64 + + - name: maven-package-x86-64 + runAfter: ["clone-repo-x86-64"] + taskRef: + kind: ClusterTask + name: maven + params: + - name: CONTEXT_DIR + value: $(params.context-dir) + workspaces: + - name: source + workspace: sources + subPath: src-x86_64 + - name: maven-settings + workspace: maven-settings + + - name: maven-package-aarch64 + runAfter: ["clone-repo-aarch64"] + taskRef: + kind: ClusterTask + name: maven + params: + - name: CONTEXT_DIR + value: $(params.context-dir) + workspaces: + - name: source + workspace: sources + subPath: src-aarch64 + - name: maven-settings + workspace: maven-settings + + - name: build-x86-64 + runAfter: ["maven-package-x86-64"] + taskRef: + name: buildah-build + params: + - name: context-dir + value: $(params.context-dir) + - name: containerfile-path + value: $(params.containerfile-path) + workspaces: + - name: source-workspace + workspace: sources + subPath: src-aarch64 + - name: oci-images + workspace: oci-images + + - name: build-aarch64 + runAfter: ["maven-package-aarch64"] + taskRef: + name: buildah-build + params: + - name: context-dir + value: $(params.context-dir) + - name: containerfile-path + value: $(params.containerfile-path) + workspaces: + - name: source-workspace + workspace: sources + subPath: src-aarch64 + - name: oci-images + workspace: oci-images + + - name: push-image + runAfter: ["build-x86-64", "build-aarch64"] + taskRef: + name: buildah-push + params: + - name: image-name + value: $(params.image-name) + - name: architectures + value: + - x86_64 + - aarch64 + workspaces: + - name: oci-images + workspace: oci-images + - name: dockerconfig + workspace: registry-token diff --git a/examples/quarkus/tekton/pipelinerun.yaml b/examples/quarkus/tekton/pipelinerun.yaml new file mode 100644 index 0000000..3ae9837 --- /dev/null +++ b/examples/quarkus/tekton/pipelinerun.yaml @@ -0,0 +1,59 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + generateName: quarkus-getting-started- +spec: + pipelineRef: + name: quarkus-getting-started + params: + - name: git-url + value: https://github.com/nmasse-itix/tekton-pipeline-multiarch.git + - name: image-name + value: quay.io/nmasse_itix/quarkus-getting-started-multiarch + - name: context-dir + value: examples/quarkus/src + - name: containerfile-path + value: examples/quarkus/src/src/main/docker/Dockerfile.jvm + workspaces: + - name: oci-images + volumeClaimTemplate: + spec: + storageClassName: efs-csi + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi + - name: sources + volumeClaimTemplate: + spec: + storageClassName: efs-csi + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Gi + - name: maven-settings + emptyDir: {} + - name: registry-token + secret: + secretName: quay-authentication + taskRunTemplate: + serviceAccountName: buildbot + taskRunSpecs: + - pipelineTaskName: maven-package-x86-64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: amd64 + - pipelineTaskName: maven-package-aarch64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: arm64 + - pipelineTaskName: build-x86-64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: amd64 + - pipelineTaskName: build-aarch64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: arm64 diff --git a/tekton/task-buildah-build.yaml b/tekton/task-buildah-build.yaml index 0cbcc10..79aa125 100644 --- a/tekton/task-buildah-build.yaml +++ b/tekton/task-buildah-build.yaml @@ -7,6 +7,9 @@ spec: - name: context-dir type: string default: . + - name: containerfile-path + type: string + default: Containerfile workspaces: - name: source-workspace description: Workspace containing source code @@ -17,14 +20,14 @@ spec: emptyDir: {} steps: - name: build - image: registry.redhat.io/rhel8/buildah@sha256:b48f410efa0ff8ab0db6ead420a5d8d866d64af846fece5efb185230d7ecf591 + image: registry.redhat.io/rhel8/buildah:8.9 env: - name: STORAGE_DRIVER value: vfs script: | #!/bin/bash set -Eeuo pipefail - buildah bud -t localhost/image:$(uname -m) $(workspaces.source-workspace.path)/$(params.context-dir) + buildah bud -t localhost/image:$(uname -m) -f $(workspaces.source-workspace.path)/$(params.containerfile-path) $(workspaces.source-workspace.path)/$(params.context-dir) buildah push localhost/image:$(uname -m) oci-archive:/srv/oci-images/$(uname -m).tar securityContext: capabilities: diff --git a/tekton/task-buildah-push.yaml b/tekton/task-buildah-push.yaml index fc5cf30..05f4c17 100644 --- a/tekton/task-buildah-push.yaml +++ b/tekton/task-buildah-push.yaml @@ -19,7 +19,7 @@ spec: emptyDir: {} steps: - name: push - image: registry.redhat.io/rhel8/buildah@sha256:b48f410efa0ff8ab0db6ead420a5d8d866d64af846fece5efb185230d7ecf591 + image: registry.redhat.io/rhel8/buildah:8.9 env: - name: STORAGE_DRIVER value: vfs