Skip to content

leeyeekee/OpenShiftPipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 

Repository files navigation

OpenShift Pipeline

This tutorial aims at showcasing the OpenShift Pipeline feature which is based on Tekton.

Pre-Requisite

  1. OpenShift version 4.8
  2. Fork a sample nodejs application from https://github.com/leeyeekee/nodejs-ex.git

OpenShift Pipeline Key Concepts

OpenShift Pipelines provide a set of standard Custom Resource Definitions (CRDs) that act as the building blocks from which you can assemble a CI/CD pipeline for your application.

image

Task

A Task is the smallest configurable unit in a Pipeline. It is essentially a function of inputs and outputs that form the Pipeline build. It can run individually or as a part of a Pipeline. A Pipeline includes one or more Tasks, where each Task consists of one or more steps. Steps are a series of commands that are sequentially executed by the Task.

Pipeline

A Pipeline consists of a series of Tasks that are executed to construct complex workflows that automate the build, deployment, and delivery of applications. It is a collection of PipelineResources, parameters, and one or more Tasks. A Pipeline interacts with the outside world by using PipelineResources, which are added to Tasks as inputs and outputs.

PipelineRun

A PipelineRun is the running instance of a Pipeline. A PipelineRun initiates a Pipeline and manages the creation of a TaskRun for each Task being executed in the Pipeline.

Trigger

A Trigger captures an external event, such as a Git pull request and processes the event payload to extract key pieces of information. This extracted information is then mapped to a set of predefined parameters, which trigger a series of tasks that may involve creation and deployment of Kubernetes resources. You can use Triggers along with Pipelines to create full-fledged CI/CD systems where the execution is defined entirely through Kubernetes resources.

OpenShift Pipeline Tutorial Demonstration

image

Steps

  1. Deploy the OpenShift Pipeline Operator

  2. Create MyDev and MyStage project namespaces

  3. Grant ServiceAccounts to the project namespaces

     oc adm policy add-role-to-group edit system:serviceaccounts -n mydev
    
     oc adm policy add-role-to-group edit system:serviceaccounts -n mystage
    
     oc adm policy add-role-to-user system:image-puller system:serviceaccounts:mystage -n mydev
    
     oc adm policy add-role-to-user system:deployer system:serviceaccounts:mydev -n mystage
    
  4. Deploy the nodejs application with a OpenShift Pipeline onto the MyDev project namespace

  5. Extend the pipeline to deploy to the MyStage project namespace Add a pipeline tasks of type openshift-client to tag the image and deploy to MyStage project namespace

     Display Name : tag-image
    
     Script : 
    
       oc tag mydev/$(params.APP_NAME):latest mydev/$(params.APP_NAME):promote-stage
    
     Display Name : deploy-stage
    
     Script : 
    
       oc project mystage
    
       oc delete all --selector app=$(params.APP_NAME)
    
       oc new-app mydev/$(params.APP_NAME):promote-stage -n mystage --as-deployment-config
    
       oc scale --replicas=3 dc $(params.APP_NAME)
    
       oc expose service $(params.APP_NAME)
    
  6. Create a pipeline trigger when a developer commit and push the source code changes

Tutorial Demonstration Video

https://youtu.be/Jg3nhbXJ14s

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published