Getting Started:
Common Scenarios:
Troubleshooting:
When running Tekton Pipelines in production environments, you'll likely encounter scenarios where the default Pod configuration doesn't meet your needs:
Common Challenges:
Without Pod Templates:
You would need to modify individual Task definitions or create multiple versions of the same Task with different configurations, leading to:
How Pod Templates Solve These Problems:
Pod templates provide a flexible, multi-level configuration system that allows you to:
Pod templates are configuration fields that allow you to customize the Pod specifications for your Tekton TaskRuns and PipelineRuns. They define a portion of a PodSpec that Tekton uses to configure the Pods executing your Tasks and Pipelines.
Pod templates can be configured at different levels (global, per-pipeline, per-task), providing flexibility to apply configurations with varying scopes and priorities.
For detailed information about Pod template concepts and supported fields, see Pod Templates Concepts.
Pod templates are useful in the following scenarios:
runAsUser, fsGroup) to meet security policiesUse this decision guide to quickly determine which configuration method fits your needs:
| Scenario | Recommended Method | Why |
|---|---|---|
| One-off execution with special requirements | Method 1: TaskRun | Apply to a single TaskRun only. |
| Testing a configuration before applying globally | Method 1: TaskRun | Test safely without affecting other executions. |
| One specific pipeline needs special configuration | Method 2: PipelineRun | Override for this pipeline only without affecting others. |
| Different tasks in the same pipeline need different configurations | Method 3: TaskRunSpecs | Fine-grained control per task. Useful for mixed workloads (official + custom Tasks). |
| Set baseline configuration for all pipelines in the cluster | Method 4: Global (TektonConfig) | Apply once, affects all executions. Good for security defaults, image pull secrets. |
Pod templates can be configured at four different levels, each serving different purposes and having different scopes of impact.
Configure Pod template directly in a TaskRun. This affects only the specific TaskRun execution.
Use Case: Apply specific configurations to individual TaskRun executions.
Configuration Location: spec.podTemplate in TaskRun
Example:
Configure Pod template at the PipelineRun level. This affects all Tasks within the PipelineRun unless overridden by taskRunSpecs.
Use Case: Apply consistent configurations to all Tasks in a Pipeline execution.
Configuration Location: spec.taskRunTemplate.podTemplate in PipelineRun
Example:
Configure Pod template for specific Tasks within a PipelineRun. This allows fine-grained control over individual Tasks in a Pipeline.
Use Case: Apply different configurations to different Tasks within the same Pipeline execution.
Configuration Location: spec.taskRunSpecs[].podTemplate in PipelineRun
Example:
Configure a global default Pod template that applies to all TaskRuns and PipelineRuns in the cluster.
Use Case: Apply consistent baseline configurations across all Pipeline executions in the cluster.
Configuration Location: spec.pipeline.default-pod-template in TektonConfig
Security Best Practice
It is recommended to use a non-root user (e.g., runAsUser: 65532) as the default configuration to follow the principle of least privilege. Official Tekton Tasks are designed to work with UID 65532. Only override to runAsUser: 0 for specific TaskRuns/PipelineRuns when required by custom images or legacy applications.
Why UID 65532?
UID 65532 is the standard non-root user ID used by official Tekton Tasks and most Tekton catalog Tasks. This ID follows the principle of least privilege and is widely adopted in the Tekton ecosystem for security best practices.
fsGroup: Sets the group ID for all containers in the Pod. This ensures files created by the Pod are owned by the specified group, allowing proper file access permissions.
Steps:
Edit the TektonConfig resource:
Add or modify the spec.pipeline.default-pod-template configuration:
Verify the configuration:
| Method | Scope | Priority Level | When to Use | Advantages | Disadvantages |
|---|---|---|---|---|---|
| Method 1: TaskRun | Single TaskRun execution | Medium | Testing, one-off executions | Safe, isolated, easy to test | Need to configure for each TaskRun |
| Method 2: PipelineRun | All tasks in one PipelineRun | Medium | Pipeline-specific requirements | Easy to manage, applies to all tasks in pipeline | Must specify for each PipelineRun |
| Method 3: TaskRunSpecs | Specific tasks within a PipelineRun | Highest | Mixed workloads (official + custom Tasks) | Fine-grained control per task | More complex configuration |
| Method 4: Global (TektonConfig) | All TaskRuns/PipelineRuns in cluster | Lowest | Baseline security and defaults | Set once, affects all executions | Global impact, requires cluster permissions |
Priority Rule: When the same field is configured at multiple levels, the configuration with the higher priority level takes effect. TaskRunSpecs (highest) > PipelineRun/TaskRun (medium) > Global (lowest).
Pod template configurations follow a clear priority hierarchy. When multiple configurations exist for the same field, the higher priority configuration overrides the lower priority one.
Priority Order (Highest to Lowest):
Merging Behavior:
Example:
If you have:
runAsUser: 65532 (secure default)runAsUser: 0 (override for custom images)runAsUser: 65532 (restore secure default for official Tasks)The result will be:
runAsUser: 65532runAsUser: 0Scenario: Set a secure default configuration with non-root user for all Pipeline tasks. This is the recommended baseline configuration that follows security best practices.
Global Configuration:
Note: Official Tekton Tasks and catalog Tasks are designed to work with UID 65532. This configuration ensures all Pipeline executions run securely by default.
Scenario: Configure image pull secrets for accessing private registries.
PipelineRun Configuration:
Scenario: Run build tasks on high-performance nodes.
TaskRunSpecs Configuration:
Scenario: Your global default uses secure non-root user (65532), but you have a pipeline with custom images that require root access. Use TaskRunSpecs to override for specific tasks while maintaining secure defaults for official Tasks.
Best Practice: Only override runAsUser to 0 for specific tasks that truly require root access. Let official Tekton Tasks use the secure default (65532).
Scenario: You migrated from Alauda DevOps Tekton v3 to Alauda DevOps Pipelines and set the global default-pod-template to runAsUser: 0 for backward compatibility with existing custom images. Now you want to use official Tekton catalog Tasks, which require runAsUser: 65532 and fsGroup: 65532.
Solution: Override the global configuration at the PipelineRun level for Pipelines that use official Tasks.
Current Global Configuration (set during migration):
PipelineRun Configuration for Official Tasks:
Alternative: Use TaskRunSpecs for mixed scenarios:
Long-term Recommendation: Gradually update your custom images to support non-root users, then change the global default to runAsUser: 65532 for better security.
Scenario: You are currently migrating from Alauda DevOps Tekton v3 to Alauda DevOps Pipelines and your custom images are not yet updated to support non-root users. You need a temporary solution to run legacy pipelines while you update your images.
Context: Unlike Example 5 (where migration is complete with global runAsUser: 0), this scenario is for users who:
runAsUser: 65532)Temporary PipelineRun Configuration:
Migration Path:
Important: This is a temporary workaround during active migration.
These are the most common issues users encounter. Review these before configuring Pod templates:
❌ Setting Global runAsUser to 0: Do not set runAsUser: 0 in the global default-pod-template. This violates security best practices and exposes all Pipeline executions to unnecessary risk. Always use runAsUser: 65532 as the global default. If you need root access, override at TaskRun/PipelineRun level only.
❌ Security Context Conflicts: Ensure Task-level security context settings (e.g., runAsNonRoot: true) are compatible with Pod template security context. Common error: container's runAsUser breaks non-root policy. See Troubleshooting: Custom Image Pod Creation Failed for solutions.
❌ Configuration Priority Misunderstanding: Remember that higher-priority configurations override lower-priority ones:
❌ Global Configuration Impact: Be cautious when modifying global default-pod-template as it affects ALL Pipeline executions in the cluster. Test changes with TaskRun/PipelineRun first.
❌ YAML Formatting: When configuring default-pod-template in TektonConfig, use the pipe (|) character for proper YAML multiline string formatting:
Follow Security Best Practices: Always use non-root user (runAsUser: 65532) as the global default. Official Tekton Tasks are designed to work with UID 65532. Only override to runAsUser: 0 for specific tasks that require root privileges.
Start with Secure Global Defaults: Configure secure baseline settings in the global default-pod-template:
Override Selectively: When you have custom images requiring root access, override ONLY at the TaskRun or taskRunSpecs level for those specific tasks. Do not change the global default to runAsUser: 0.
Use TaskRunSpecs for Fine-Grained Control: When different tasks in a pipeline require different security contexts (e.g., custom images vs. official Tasks), use taskRunSpecs to apply different configurations.
Document Security Exceptions: Clearly document why specific tasks require root access (runAsUser: 0). Review these exceptions regularly to see if they can be eliminated.
Test Configuration Changes: Test Pod template configuration changes in non-production environments before applying to production, especially security context changes.
After applying Pod template configurations, verify they are effective:
Check that the configuration is applied to the ConfigMap:
Expected output should show your configured pod template.
Step 1: Find the Pod created by your TaskRun or PipelineRun
Step 2: Verify the Pod specification