Labels and Annotations
Tekton allows you to use custom Kubernetes Labels to easily mark Tekton entities belonging to the same conceptual execution chain. Tekton also automatically adds select labels to more easily identify resource relationships. This document describes the label propagation scheme, automatic labeling, and provides usage examples.
Label propagation
Labels propagate among Tekton entities as follows:
-
For
Pipelines
instantiated using aPipelineRun
, labels propagate automatically fromPipelines
toPipelineRuns
toTaskRuns
, and then to the associatedPods
. If a label is present in bothPipeline
andPipelineRun
, the label inPipelineRun
takes precedence. -
Labels from
Tasks
referenced byTaskRuns
within aPipelineRun
propagate to the correspondingTaskRuns
, and then to the associatedPods
. As forPipeline
andPipelineRun
, if a label is present in bothTask
andTaskRun
, the label inTaskRun
takes precedence. -
For standalone
TaskRuns
(that is, ones not executing as part of aPipeline
), labels propagate from the referencedTask
, if one exists, to the correspondingTaskRun
, and then to the associatedPod
. The same as above applies.
Automatic labeling
Tekton automatically adds labels to Tekton entities as described in the following table.
Note: *.tekton.dev
labels are reserved for Tekton’s internal use only. Do not add or remove them manually.
Label | Added To | Propagates To | Contains |
tekton.dev/pipeline |
PipelineRuns |
TaskRuns, Pods |
Name of the Pipeline that the PipelineRun references. |
tekton.dev/pipelineRun |
TaskRuns that are created automatically during the execution of a PipelineRun . |
TaskRuns, Pods |
Name of the PipelineRun that triggered the creation of the TaskRun . |
tekton.dev/task |
TaskRuns that reference an existing Task. |
Pods |
Name of the Task that the TaskRun references. |
tekton.dev/clusterTask |
TaskRuns that reference an existing ClusterTask . |
Pods |
Name of the ClusterTask that the TaskRun references. |
tekton.dev/taskRun |
Pods |
No propagation. | Name of the TaskRun that created the Pod . |
tekton.dev/memberOf |
TaskRuns that are created automatically during the execution of a PipelineRun . |
TaskRuns, Pods |
tasks or finally depending on the PipelineTask 's membership in the Pipeline . |
app.kubernetes.io/instance , app.kubernetes.io/component |
Pods , StatefulSets (Affinity Assistant) |
No propagation. | Pod affinity values for TaskRuns . |
Usage examples
Below are some examples of using labels:
The following command finds all Pods
created by a PipelineRun
named test-pipelinerun
:
kubectl get pods --all-namespaces -l tekton.dev/pipelineRun=test-pipelinerun
The following command finds all TaskRuns
that reference a Task
named test-task
:
kubectl get taskruns --all-namespaces -l tekton.dev/task=test-task
The following command finds all TaskRuns
that reference a ClusterTask
named test-clustertask
:
kubectl get taskruns --all-namespaces -l tekton.dev/clusterTask=test-clustertask
Annotations propagation
Annotation propagate among Tekton entities as follows (similar to Labels):
-
For
Pipelines
instantiated using aPipelineRun
, annotations propagate automatically fromPipelines
toPipelineRuns
toTaskRuns
, and then to the associatedPods
. If a annotation is present in bothPipeline
andPipelineRun
, the annotation inPipelineRun
takes precedence. -
Annotations from
Tasks
referenced byTaskRuns
within aPipelineRun
propagate to the correspondingTaskRuns
, and then to the associatedPods
. As forPipeline
andPipelineRun
, if a annotation is present in bothTask
andTaskRun
, the annotation inTaskRun
takes precedence. -
For standalone
TaskRuns
(that is, ones not executing as part of aPipeline
), annotations propagate from the referencedTask
, if one exists, to the correspondingTaskRun
, and then to the associatedPod
. The same as above applies.
Feedback
Was this page helpful?