epamedp/tekton-custom-task
Enhance your CI/CD pipelines with Tekton Custom Task
4.8K
Tekton Custom Task extends Kubernetes and Tekton capabilities by providing custom task implementations. These custom tasks are designed to facilitate complex workflows that standard Tekton tasks may not cover, making it a powerful tool for DevOps teams looking to extend their CI/CD pipelines with custom logic.
To get started with Tekton Custom Task, ensure you have Kubernetes and Tekton Pipelines installed in your environment. Follow these steps to deploy a custom task:
Clone the repository to your local environment.
Navigate to the config/
directory.
Apply the CRDs to your Kubernetes cluster:
kubectl apply -f config/crd/bases/
Deploy the custom tasks using:
kubectl apply -f config/samples/
Below is an example of how to define a custom task in your Tekton pipeline:
apiVersion: edp.epam.com/v1alpha1
kind: ApprovalTask
metadata:
name: approvaltask-sample
labels:
app.kubernetes.io/name: tekton-custom-task
app.kubernetes.io/managed-by: kustomize
spec:
action: Pending
description: "Approval required for the next step in the pipeline."
This example demonstrates how to run a CustomTask
named example-custom-task
within a Tekton pipeline.
This set of instructions guides you through the process of creating a custom ApprovalTask
and incorporating it into a Tekton pipeline to serve as an approval step.
To integrate the ApprovalTask
into your CI/CD pipelines, follow these steps to define the custom task and use it within a Tekton pipeline.
ApprovalTask
Create an ApprovalTask
definition by preparing a YAML file named approvaltask.yaml
with the contents below:
apiVersion: edp.epam.com/v1alpha1
kind: ApprovalTask
metadata:
name: approvaltask-example
spec:
action: Pending
description: "Approval required for the next deployment phase."
This YAML snippet creates an ApprovalTask
resource named approvaltask-example
. The task is initially set to a Pending
state, indicating it awaits approval, and it includes a description to provide context for the approval required.
ApprovalTask
in a Tekton PipelineIncorporate the ApprovalTask
within a Tekton pipeline by defining both a Pipeline
and a PipelineRun
.
Define the Pipeline
Create a file named pipeline.yaml
with the following content:
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: example-pipeline
spec:
tasks:
- name: approval-task
taskRef:
apiVersion: edp.epam.com/v1alpha1
kind: ApprovalTask
name: approvaltask-example
This pipeline, named example-pipeline
, contains a single task named approval-task
. This task references your previously defined ApprovalTask
(approvaltask-example
).
Define the PipelineRun
To initiate the pipeline execution, define a PipelineRun
in a file named pipeline-run.yaml
with the contents below:
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: example-pipeline-run
spec:
pipelineRef:
name: example-pipeline
This PipelineRun
, named example-pipeline-run
, triggers the execution of example-pipeline
.
Deploy the ApprovalTask
, the pipeline, and initiate the pipeline run by applying the YAML files to your Kubernetes cluster:
kubectl apply -f approvaltask.yaml
kubectl apply -f pipeline.yaml
kubectl apply -f pipeline-run.yaml
Tekton Custom Task supports integration with Kubernetes dashboards and notification systems. This allows for improved monitoring and alerting capabilities for your custom tasks.
Future developments include:
We welcome contributions in the form of issues and pull requests. Please follow the contributing guidelines outlined in the repository.
This project is licensed under the Apache License 2.0.
docker pull epamedp/tekton-custom-task