Overview
Sidecars enable you to:- Run services that Steps need to communicate with
- Provide test dependencies like databases or message queues
- Run Docker-in-Docker for building container images
- Set up SSH servers or other network services
- Share resources with Steps through volumes
Basic Sidecar Configuration
Define sidecars in the Task specification:Docker-in-Docker Sidecar
A common use case is running Docker commands from Steps:Sharing Data with Volumes
Sidecars and Steps can share data through volumes:Sidecar Readiness
Use readiness probes to ensure sidecars are ready before Steps start:Steps wait for sidecars with readiness probes to become ready before executing.
Startup Probes
Use startup probes for sidecars that need extra time to initialize:SSH Server Sidecar
Run an SSH server for Git operations:Workspaces in Sidecars
Sidecars can access Task workspaces:Variable Substitution in Sidecars
Sidecars support variable substitution:spec.sidecars[].namespec.sidecars[].imagespec.sidecars[].imagePullPolicyspec.sidecars[].env.valuespec.sidecars[].commandspec.sidecars[].argsspec.sidecars[].scriptspec.sidecars[].volumeMounts
Sidecar Lifecycle
Startup Order
- Sidecars start first
- Sidecars with readiness probes must become ready
- Steps execute in order
- Sidecars continue running during Step execution
Shutdown
Sidecars automatically stop when:- All Steps complete successfully
- A Step fails and the Task stops
- The TaskRun times out
Tekton sends a SIGTERM to sidecars to request graceful shutdown. If sidecars don’t exit within the grace period, they receive SIGKILL.
Resource Management
Specify resource requests and limits for sidecars:Best Practices
Use Readiness Probes
Minimize Sidecar Size
Share Data via Volumes
Use volumes instead of network communication when possible:Set Security Contexts
Common Patterns
Database for Testing
Service Mesh Proxy
Message Queue
Why isn't my sidecar starting?
Why isn't my sidecar starting?
Check these common issues:
- Image pull errors: Verify the image exists and is accessible
- Resource constraints: Ensure the cluster has sufficient resources
- Security policies: Check if security contexts or policies block the sidecar
- Volume mount conflicts: Verify volume mounts don’t conflict with Step mounts
How do Steps communicate with sidecars?
How do Steps communicate with sidecars?
Steps communicate with sidecars via:
- Localhost networking: Sidecars listen on
localhostor127.0.0.1 - Shared volumes: Exchange files through mounted volumes
- Environment variables: Pass configuration via env vars