Tekton is a powerful and flexible open-source framework for creating cloud-native Continuous Integration and Continuous Delivery (CI/CD) systems. It provides a set of Kubernetes-style resources for defining and executing CI/CD pipelines, allowing developers to automate the building, testing, and deployment of their applications in a cloud-native manner.
1. **Task Definition:**
```yaml apiVersion: tekton.dev/v1beta1 kind: Task metadata:
name: build-imagespec:
steps: - name: build image: docker:latest command: ["docker", "build", "-t", "$(params.image-name)", "."]```
This defines a Task named `build-image` that builds a Docker image using the specified `image-name` parameter.
2. **Pipeline Definition:**
```yaml apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata:
name: my-pipelinespec:
tasks: - name: build taskRef: name: build-image params: - name: image-name value: my-org/my-app:latest - name: deploy taskRef: name: deploy-app runAfter: - build```
This defines a Pipeline named `my-pipeline` that consists of two tasks: `build` and `deploy`. The `build` task builds a Docker image, and the `deploy` task deploys the image to a Kubernetes cluster.
3. **PipelineRun:**
```yaml apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata:
name: my-pipeline-runspec:
pipelineRef: name: my-pipeline```
This creates a PipelineRun that executes the `my-pipeline` pipeline.