Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TKNECO-90] Document How to Setup the Catalog #47

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,110 @@ Triggers, and any other element that can be used with `tektoncd/pipeline`).
- Possibly driving API "feature"/changes
Because we will write a lot of task, use them, … we should be able to find gap or
enhancements in the API, and propose them as TEPs (with data).

# Usage Examples


This section explains how to use the tasks supported in this repository with the help of various tools like Tekton Resolvers as well as Pipelines as Code.
Aneesh-M-Bhat marked this conversation as resolved.
Show resolved Hide resolved

## Using Tekton Resolvers
Aneesh-M-Bhat marked this conversation as resolved.
Show resolved Hide resolved

Make sure kubectl is installed, if not install it using this [link](https://kubernetes.io/docs/tasks/tools/).

To use our tasks, you can create a Pipeline Resource as follows:

```yaml
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
labels:
name: example-pipeline
name: example-pipeline
spec:
params:
# Customize the Params as needed by your chosen tasks
- name: APP_NAME
type: string
default: example
- name: IMAGE_PREFIX
type: string
default: "test"

workspaces:
- name: source

tasks:
# Add or Reference other tasks as needed
- name: example-task
taskRef:
resolver: git
params:
- name: url
value: https://github.com/openshift-pipelines/tektoncd-catalog.git
- name: revision
value: p
- name: pathInRepo
value: experimental/tasks/go-crane-image/v0.1.0/go-crane-image.yaml
workspaces:
- name: source
workspace: source
params:
- name: app
value: $(params.APP_NAME)
- name: image
value:
prefix: $(params.IMAGE_PREFIX)
```
Note: Add either a secret or update the service account with the git credentials
Aneesh-M-Bhat marked this conversation as resolved.
Show resolved Hide resolved

Also for this example we have used a PersistentVolumeClaim as follows:

```yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
name: test
name: test
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 250Mi
```

Then use the following commands to apply & run the above Pipeline

- Create PVC resource: kubectl apply -f pvc.yaml
- Create Pipeline: kubectl apply -f pipeline.yaml
- PipelineRun: tkn pipeline start example-pipeline --workspace="name=source,claimName=test,subPath=source" --showlog
Aneesh-M-Bhat marked this conversation as resolved.
Show resolved Hide resolved

To learn more about resolver, use this [link](https://tekton.dev/docs/pipelines/resolution-getting-started/).

## Using Pipelines as Code

Make sure all the prerequisites are present for using pac (check that [here](https://pipelinesascode.com/docs/install/getting-started/)

To create a template PipelineRun resource, you can use the command: tkn pac generate
After this it'll create a PipelineRun template, which can then be customized similar to the previous example to incorporate our tasks

Some annotations to look for are:
```
annotations:
pipelinesascode.tekton.dev/on-event: "[push]"
pipelinesascode.tekton.dev/on-target-branch: "[main]"
pipelinesascode.tekton.dev/max-keep-runs: "5"
Aneesh-M-Bhat marked this conversation as resolved.
Show resolved Hide resolved
```

## Cloning the repo (Not Recommended)

You can also consume our resources by cloning this repository and manually creating the resources in the cluster as well

Helpful commands:
- git clone https://github.com/openshift-pipelines/tektoncd-catalog.git
- kubectl apply path-of-task.yaml (replace path-of-task with relevant task's path)

After adding the Tasks to the cluster, you can use them as needed for other resources
Aneesh-M-Bhat marked this conversation as resolved.
Show resolved Hide resolved