Assembling a pipeline
A Pipeline represents a CI/CD flow and is defined by the Tasks to be executed. It specifies how the Tasks interact with each other and their order of execution using the inputs , outputs, and the run-After parameters. It is designed to be generic and reusable in multiple applications and environments.
In this section you will create a Pipeline that takes the source code of the application from GitHub and then builds and deploys it on OpenShift:
Procedure
-
Copy the contents of the following sample
PipelineYAML file and save it:apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: build-and-deploy spec: resources: - name: api-repo type: git - name: api-image type: image - name: ui-repo type: git - name: ui-image type: image tasks: - name: build-api taskRef: name: buildah kind: ClusterTask resources: inputs: - name: source resource: api-repo outputs: - name: image resource: api-image params: - name: TLSVERIFY value: "false" - name: apply-api-manifests taskRef: name: apply-manifests resources: inputs: - name: source resource: api-repo runAfter: - build-api - name: update-api-image taskRef: name: update-deployment resources: inputs: - name: image resource: api-image params: - name: deployment value: "api" runAfter: - apply-api-manifests - name: build-ui taskRef: name: s2i-python-3 kind: ClusterTask resources: inputs: - name: source resource: ui-repo outputs: - name: image resource: ui-image params: - name: TLSVERIFY value: "false" - name: apply-ui-manifests taskRef: name: apply-manifests resources: inputs: - name: source resource: ui-repo runAfter: - build-ui - update-api-image - name: update-ui-image taskRef: name: update-deployment resources: inputs: - name: image resource: ui-image params: - name: deployment value: "ui" runAfter: - apply-ui-manifestsThis
Pipelineperforms the following tasks:-
Clones the source code of the back-end application from the
api-repoGit repository and the front-end application from theui-repo resourceGit repository. -
Builds the container image for the front-end using the
s2i-python-3task that generates a Dockerfile for the application using Source-to-Image (S2I). -
Builds the container image for the back-end using the
buildahtask that usesBuildahto build the image. -
The application image is pushed to an image registry.
-
The new application image is deployed on OpenShift using the
apply-manifestsandupdate-deploymenttasks.Pipelinesin Tekton are designed to be generic and re-usable across environments and stages through the applications lifecycle. They abstract away the specifics of the Git source repository and image registries to be used duringPipelineexecution.The execution order of the tasks is determined by the dependencies defined between the tasks using the
inputsandoutputsparameters, and the explicit orders that are defined usingrunAfter.
-
-
Create the
Pipeline:$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/master/pipeline/pipeline.yaml
-
Verify that the
Pipelinehas been added to the application as follows:$ tkn pipeline ls NAME AGE LAST RUN STARTED DURATION STATUS build-and-deploy 1 minute ago --- --- --- ---