IBMDeveloperMEA / oc-devops

Let's talk about Tekton pipelines!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tekton Pipelines

Steps to create a pipeline:

  • Create custom or install existing reusable Tasks
  • Create a Pipeline and PipelineResources to define your application's delivery pipeline
  • Create a PersistentVolumeClaim to provide the volume/filesystem for pipeline execution or provide a VolumeClaimTemplate which creates a PersistentVolumeClaim
  • Create a PipelineRun to instantiate and invoke the pipeline

Prerequisites

Pipeline Overview

image

Install OpenShift Pipelines Operator

  • Make sure you are on the Administrator perspective on the web console.
  • Go to Operators > OperatorHub and search for 'OpenShift Pipelines'.
  • Click on Red Hat OpenShift Pipelines Operator, and then install.
  • Leave the default Settings and click on Subscribe.
  • Once the operator is installed, you can find it in Operators > Installed Operators section.

View & Edit the buildah cluster task

  • From the administrator perspective, go to Pipelines > Tasks and go to the 'Cluster Tasks' tab.
  • Select the 'buildah' cluster task
    buildah
  • Click on 'Actions' dropdown from the top right, and select 'Edit Cluster Task'.
    buildah-1
  • Look for the variable TLSVERIFY in the YAML document. Notice that the default value of TLSVERIFY is set to true.
    tlsverify
  • Change the default value of TLSVERIFY from true to false. Click 'Save' and then 'Reload' to save your changes. TLSVERIFYFALSE

Create project & Service account

  • Create a project for the sample application that you will be using in this tutorial:
oc new-project ci-env
oc new-project dev-env
oc new-project stage-env
  • Make sure you are in the ci-env project
oc project ci-env
  • Run the following command to see the pipeline service account:
oc get serviceaccount pipeline
  • Give required permissions for the pipeline service account in the ci-env project to be able to make changes in dev-env and stage-env projects.
oc adm policy add-scc-to-user privileged system:serviceaccount:ci-env:pipeline -n ci-env
oc adm policy add-scc-to-user privileged system:serviceaccount:ci-env:pipeline -n dev-env
oc adm policy add-scc-to-user privileged system:serviceaccount:ci-env:pipeline -n stage-env
oc adm policy add-role-to-user edit system:serviceaccount:ci-env:pipeline -n ci-env
oc adm policy add-role-to-user edit system:serviceaccount:ci-env:pipeline -n dev-env
oc adm policy add-role-to-user edit system:serviceaccount:ci-env:pipeline -n stage-env

Create Tasks

  • create apply-manifest task
oc create -f https://raw.githubusercontent.com/IBMDeveloperMEA/oc-devops/main/tasks/apply-manifest-task.yaml -n ci-env
  • create update-deployment task
oc create -f https://raw.githubusercontent.com/IBMDeveloperMEA/oc-devops/main/tasks/update-deployment-task.yaml -n ci-env
  • create test-app task
oc create -f https://raw.githubusercontent.com/IBMDeveloperMEA/oc-devops/main/tasks/test-task.yaml -n ci-env
  • List the tasks you just created
tkn task ls
  • List ClusterTasks
tkn clustertask ls

Create Pipeline

  • Create the pipeline using the following command
oc create -f https://raw.githubusercontent.com/IBMDeveloperMEA/oc-devops/main/pipeline.yaml -n ci-env
  • Show the newly created pipeline
tkn pipeline ls

Create PersistentVolumeClaim (PVC)

  • Create PVC
oc create -f https://raw.githubusercontent.com/IBMDeveloperMEA/oc-devops/main/pvc.yaml -n ci-env
oc get pvc -n ci-env

Trigger Pipeline

  • Trigger the pipeline
tkn pipeline start e2e-pipeline
  • Get the list of existing pipelinerun
tkn pipelinerun ls
  • Track the logs for your pipelinerun
tkn pipeline logs -f

Resources

About

Let's talk about Tekton pipelines!