Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
121 changes: 121 additions & 0 deletions examples/tekton-pipelines/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#### Install tekton pipelines on host cluster
```
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
```

Optionally install tekton-dashboard on the host cluster
```
kubectl apply --filename https://storage.googleapis.com/tekton-releases/dashboard/latest/tekton-dashboard-release.yaml
```

#### Deploy vcluster with tekton plugin
```
vcluster create vcluster -f https://raw.githubusercontent.com/loft-sh/vcluster-generic-crd-sync-plugin/main/examples/tekton-pipelines/plugin.yaml
```

#### Create some tekton Tasks and Pipelines
Some basic tasks
```
cat << EOF | kubectl apply -f -
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: hello
spec:
params:
- name: name
type: string
steps:
- name: hello
image: ubuntu
command:
- echo
args:
- "hello $(params.name)!"

---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: greeting
spec:
params:
- name: name
type: string
steps:
- name: greeting
image: ubuntu
command:
- echo
args:
- "greetings $(params.name)!"

---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: goodbye
spec:
params:
- name: name
type: string
steps:
- name: goodbye
image: ubuntu
command:
- echo
args:
- "goodbye $(params.name)!"

EOF
```

A pipeline that uses these tasks
```
cat << EOF | kubectl apply -f -
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: greetings
spec:
params:
- name: name
type: string
default: "anonymous"
tasks:
- name: hello
taskRef:
name: hello
params:
- name: name
value: "$(params.name)"
- name: greeting
taskRef:
name: greeting
params:
- name: name
value: "$(params.name)"
- name: goodbye
taskRef:
name: goodbye
params:
- name: name
value: "$(params.name)"
EOF
```

#### Run the pipeline with a PipelineRun
```
cat << EOF | kubectl apply -f -
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: greetings-
spec:
params:
- name: name
value: ishan
pipelineRef:
name: greetings
EOF
```
68 changes: 68 additions & 0 deletions examples/tekton-pipelines/plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
plugin:
knative-serving:
image: ghcr.io/loft-sh/vcluster-generic-crd-plugin:latest
imagePullPolicy: Always
rbac:
role:
extraRules:
- apiGroups: ["tekton.dev"]
resources: ["tasks", "taskruns", "pipelines", "pipelineruns"]
verbs: ["create", "delete", "patch", "update", "get", "list", "watch"]
env:
- name: CONFIG
value: |-
version: v1beta1
mappings:
- fromVirtualCluster:
apiVersion: tekton.dev/v1beta1
kind: Task
reversePatches:
- op: copyFromObject
fromPath: status
path: status
- fromVirtualCluster:
apiVersion: tekton.dev/v1beta1
kind: TaskRun
patches:
- op: rewriteName
path: spec.taskRef.name
reversePatches:
- op: copyFromObject
fromPath: status
path: status
- fromVirtualCluster:
apiVersion: tekton.dev/v1beta1
kind: Pipeline
patches:
- op: rewriteName
path: spec.tasks[*].taskRef.name
- op: rewriteName
path: spec.resources[*].name
- op: rewriteName
path: spec.results[*].name
reversePatches:
- op: copyFromObject
fromPath: status
path: status
- fromVirtualCluster:
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
patches:
- op: rewriteName
path: spec.pipelineRef.name
reversePatches:
- op: copyFromObject
fromPath: status
path: status
- op: copyFromObject
fromPath: spec.serviceAccountName
path: spec.serviceAccountName
conditions:
- empty: true
path: spec.serviceAccountName
- op: copyFromObject
fromPath: spec.timeout
path: spec.timeout
conditions:
- empty: true
path: spec.timeout