Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
# https://github.com/MartinHeinz/tekton-kickstarter/blob/master/misc/config.yaml apiVersion: v1 kind: ConfigMap metadata: name: repo-app-mapping data: repo-app-mapping.yaml: | '[email protected]:kelseyhightower/nocode.git': 'nocode' '[email protected]:MartinHeinz/blog-frontend.git': 'blog-backend' '[email protected]:MartinHeinz/game-server-operator.git': 'game-server-operator' '[email protected]:MartinHeinz/python-project-blueprint.git': 'sample-python-app' --- # https://github.com/MartinHeinz/tekton-kickstarter/blob/master/tasks/get-application-name/get-application-name.yaml apiVersion: tekton.dev/v1beta1 kind: ClusterTask metadata: name: get-application-name spec: params: - name: repository-url type: string - name: mapping-file type: string steps: - name: get-application-name image: mikefarah/yq script: | #!/usr/bin/env sh set -xe yq e '."$(params.repository-url)"' /config/$(params.mapping-file) | tr -d '\012\015' > /tekton/results/application-name results: - name: application-name # Can be accessed by other Tasks with $(tasks.get-application-name.results.application-name) workspaces: - name: config mountPath: /config
Another common thing that you might need in your Tasks is some kind of a storage where you can write data that can be used by subsequent steps in the Task or by other Tasks in the pipeline. The most common use case for this would be a place to fetch git repo. This kind of a storage is called workspace in Tekton and the following example shows a Tasks that mounts and clears the storage using rmdir:
Final thing I want to show here is the usage of sidecar containers. These are not so common, but can be useful when you need to run some service (which your Task depends on) for the duration of Task execution. One such service can be Docker daemon sidecar with exposed socket. To demonstrate this we can create a Task that performs Docker image efficiency analysis using tool called Dive:
This covers most of the features of Tekton Tasks, but one thing I didn't mention so far and you will surely run into when reading Tekton docs is PipelineResource object, which can be used as Tasks input or output - for example GitHub sources as input or Docker image as output. So, why haven't I mentioned it yet? Well, PipelineResource is part of Tekton that I prefer to not use for a couple of reasons:
Tekton Design Principles
Related posts
- Is there a way to run a one-off pod that would work as a command line tool?
- Is the left guy sad because he knows everything?
- Designing a company’s CI/CD system, please recommend resources
- Fast-Kubeflow: Kubeflow Tutorial, Sample Usage Scenarios (Howto: Hands-on LAB)
- Getting Started with Tekton Pipelines: A Comprehensive Guide