diff --git a/examples/tekton-pipelines/README.md b/examples/tekton-pipelines/README.md new file mode 100644 index 00000000..b6aedf94 --- /dev/null +++ b/examples/tekton-pipelines/README.md @@ -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 +``` \ No newline at end of file diff --git a/examples/tekton-pipelines/plugin.yaml b/examples/tekton-pipelines/plugin.yaml new file mode 100644 index 00000000..07038d61 --- /dev/null +++ b/examples/tekton-pipelines/plugin.yaml @@ -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 \ No newline at end of file