Pipeline Resources

At the end of this chapter you will be able to :

Prerequisite

The following checks ensure that each chapter exercises are done with the right environment settings.

  • Minikube

  • OpenShift

  • Kubernetes should be v1.19+

kubectl version --short

The output should be like

Client Version: v1.23.3
Server Version: v1.23.3
  • OpenShift CLI should be 4.8

oc version

The output should be like

Client Version: v1.23.3
Server Version: 4.8
Kubernetes Version: v1.23.3
  • Make sure to be on tektontutorial OpenShift project

oc project -q

If you are not on tektontutorial project, then run following command to change to tektontutorial project:

oc project tektontutorial

Ensure Tekton piplines is deployed and the API is available for use

kubectl api-resources --api-group='tekton.dev'

The command show an output like:

NAME                SHORTNAMES   APIGROUP     NAMESPACED   KIND
clustertasks                     tekton.dev   false        ClusterTask
conditions                       tekton.dev   true         Condition
pipelineresources                tekton.dev   true         PipelineResource
pipelineruns        pr,prs       tekton.dev   true         PipelineRun
pipelines                        tekton.dev   true         Pipeline
runs                             tekton.dev   true         Run
taskruns            tr,trs       tekton.dev   true         TaskRun
tasks                            tekton.dev   true         Task

Create a pipeline resource

If you are not in tutorial chapter folder, then navigate to the folder:

cd $TUTORIAL_HOME/resources

The following snippet shows what a Tekton PipelineResource YAML looks like:

apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: git-source
spec:
  type: git
  params:
    - name: url
      value: https://github.com/redhat-scholars/tekton-tutorial-greeter
    - name: revision
      value: master
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: tekton-tutorial-greeter-image
spec:
  type: image
  params:
    - name: url
      value: example.com/rhdevelopers/tekton-tutorial-greeter

Each pipeline resource has:

  • name: the name using which it will be referred in other places

  • type: the type of the pipeline resource, in this example we have two types

    • git - this type of resource refers to a GitHub repository

    • image - this type of resource is linux container image

  • params: each type can have one or more parameters that will be used to configure the underlying type. In the above example for the git-source pipeline resource, the parameters url and revision are used to identify the GitHub repository url and revision of the sources respectively.

More details on other types of pipeline resource types is available here.

Deploy a pipeline resource

The pipeline resource could be created using the command:

kubectl apply -n tektontutorial -f build-resources.yaml
pipelineresource.tekton.dev/git-source created
pipelineresource.tekton.dev/tekton-tutorial-greeter-image created

See what you have deployed

We will use the Tekton cli to inspect the created resources

tkn res ls

The above command should list two resources as shown below:

NAME                            TYPE    DETAILS
git-source                      git     url: https://github.com/redhat-scholars/tekton-tutorial
tekton-tutorial-greeter-image   image   url: example.com/rhdevelopers/tekton-tutorial-greeter

All Tekton API resources/objects has the describe option that gives more details of respective Tekton API object.

e.g. To describe the PipelineResource that we just created, run:

tkn res describe git-source
Name:                    git-source
Namespace:               tektontutorial
PipelineResource Type:   git

Params
NAME       VALUE
url        https://github.com/redhat-scholars/tekton-tutorial
revision   master

Secret Params
No secret params

Use the command help via tkn res --help