diff --git a/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc b/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc index 203f6439d6..b0a07d97b8 100644 --- a/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc +++ b/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc @@ -98,6 +98,16 @@ xref:cloud/operator/build-and-deploy-workflows.adoc[] Learn how to build and deploy workflow services with {operator_name} -- + +[.card] +-- +[.card-title] +xref:cloud/operator/build-workflow-images-with-tekton.adoc[] +[.card-description] +Learn how to build workflow services using Tekton +-- + + [.card] -- [.card-title] diff --git a/serverlessworkflow/modules/ROOT/pages/cloud/operator/build-workflow-images-with-tekton.adoc b/serverlessworkflow/modules/ROOT/pages/cloud/operator/build-workflow-images-with-tekton.adoc new file mode 100644 index 0000000000..7b441589dc --- /dev/null +++ b/serverlessworkflow/modules/ROOT/pages/cloud/operator/build-workflow-images-with-tekton.adoc @@ -0,0 +1,142 @@ += Building Workflows Images with Tekton +:compat-mode!: +// Metadata: +:description: Building Workflow Images with Tekton +:keywords: kogito, workflow, serverless, operator, kubernetes, minikube, openshift, containers, tekton, pipelines + +This document describes how to build a Workflow Application on a Kubernetes cluster using the Tekton pipeline. + + +.Prerequisites +You have a git repo containing your workflow and the dockerfile to build the workflow as a docker/podman image. + +[NOTE] +==== +If you are using Openshift you can install the Red Hat Pipeline Operator, if you are using Minikube you can follow this link:https://github.com/tektoncd/pipeline/blob/main/docs/developers/local-setup.md#using-minikube[tekton guide for Minikube] +If using Kind you can follow this link:https://github.com/tektoncd/plumbing/tree/main/hack[Tekton guide for Kind] on plain kubernetes cluster you can follow this link:https://tekton.dev/docs/pipelines/install/[Tekton guide for kubernetes] +==== + + +== Create The pipeline +In the namespace `kogito-serverless-operator-system` where is deployed the Kogito Serverless Operator in the pipelines menu open the item Pipeline and go inthe create, copy the following yaml. +It contains a pipeline to clone your image workflow repo, build the image anbd push to the local image registry. + + +---- +apiVersion: tekton.dev/v1beta1 +kind: Pipeline +metadata: + name: custom-workflow-image-pipeline + namespace: kogito-serverless-operator-system +spec: + params: + - description: name of the deployment to be patched + name: deployment-name + type: string + - description: url of the git repo for the code of deployment + name: git-url + type: string + - default: pipelines-1.9 + description: revision to be used from repo of the code for deployment + name: git-revision + type: string + - description: image to be built from the code + name: IMAGE + type: string + tasks: + - name: fetch-repository + params: + - name: url + value: $(params.git-url) + - name: subdirectory + value: '' + - name: deleteExisting + value: 'true' + - name: revision + value: $(params.git-revision) + taskRef: + kind: ClusterTask + name: git-clone + workspaces: + - name: output + workspace: shared-workspace + - name: build-image + params: + - name: IMAGE + value: $(params.IMAGE) + - name: TLSVERIFY + value: 'false' + runAfter: + - fetch-repository + taskRef: + kind: ClusterTask + name: buildah + workspaces: + - name: source + workspace: shared-workspace + workspaces: + - name: shared-workspace +---- + +== Create The PipelineRun to execute the pipeline + +The next step is to create a pipeline run with the details of your git repo and the name of the image desidered + +in the Pipeline menu, in the item PipelineRun copy the following yaml replacing the placeholder with your values +i.e. `image registry available at image-registry.openshift-image-registry.svc:5000/` + +---- +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + generateName: custom-workflow-image-pipeline-run + namespace: kogito-serverless-operator-system +spec: + workspaces: + - name: shared-workspace + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 500Mi + params: + - name: deployment-name + value: + - name: git-url + value: https://.git + - name: git-revision + value: "main" + - name: IMAGE + value: "image-registry.openshift-image-registry.svc:5000/kogito-serverless-operator-system/:latest" + pipelineRef: + name: custom-workflow-image-pipeline +---- +You can check the execution of the pipeline in the UI, +at the end your image will be available at: +image-registry.openshift-image-registry.svc:5000/kogito-serverless-operator-system/:latest + + +== Create The PipelineRun with Tkn cli + +If you have installed the Tekton cli you can run the pipeline with the following command: +---- +tkn pipeline start kogito-serverless-operator-pipeline \ +-w name=shared-workspace,volumeClaimTemplateFile=https://raw.githubusercontent.com/kiegroup/kogito-serverless-operator/main/tekton/volume/persistent_volume.yaml \ +-p deployment-name= \ +-p git-url=https://.git \ +-p git-revision=main \ +-p IMAGE='image-registry.openshift-image-registry.svc:5000/kogito-serverless-operator-system/:latest' \ +--use-param-defaults +---- + +This command returns an id to check the execution with the cli in this way +---- +tkn pipelinerun logs custom-workflow-image-pipeline-run- -f -n +---- + +At the end your image will be cluster's internal registry, like this example: +---- +image-registry.openshift-image-registry.svc:5000/kogito-serverless-operator-system/:latest +---- \ No newline at end of file