Users can define sidecar containers to run inside a TaskRun's Pod.
There is no way currently to specify sidecar containers as part of any Tekton CRD.
It may be worth writing a short design doc describing the intended usecases and behaviour before committing to an implementation of this.
Possible Usecase: https://github.com/tektoncd/pipeline/issues/1032
Summary: User wants to launch a database and webserver in sidecar containers, await their readiness, then have a step container execute integration tests against them.
A bunch of other usecases for user-defined sidecars running alongside tasks:
I'm not sure if this is the right issue to add this thought to but I wanted to bring up the use case of sidecars that span multiple Tekton tasks. I am thinking here of expensive objects to setup like a database with a full schema that several tasks would call.
This could be an argument for allowing sidecars to be defined on a Pipeline and on a Task.
Interesting idea! Am I right in thinking that this is more like a "sidecar Pod" rather than a "sidecar Container"? Sounds like it would need more startup configuration - i.e. a Service to direct traffic to the pod running the initialized database.
My initial thought for sidecars in Pipeline resources was as a way to define containers that will be run as part of each Task's Pod, rather than as a concurrently running Pod with its own containers.
I'm thinking that the "sidecar Pod" approach might be a separate feature request entirely. I can see the usecase for it but I expect the implementation would diverge considerably from the sidecar container support described in this issue.
I've written up a short design doc for specifying sidecars in Tekton. Available here.
It doesn't address the issue of enforcing a sidecar lifecycle[1] at the moment. I've been skimming through the k8s codebase looking for the spot where the container termination flow is implemented and it looks as though the precise implementation of the grace period is delegated to the container runtime.
[1] https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods
@sbwsg Nice piece of work, thanks a lot!
With regard to the implementation of sidecar lifecycle, what are you looking for exactly?
Is there more to it?
@aristosvo Referring specifically to https://github.com/tektoncd/pipeline/issues/1131 : the ability to signal to sidecars that they're going to be terminated soon so they can clean up / flush buffers etc.
Most helpful comment
I've written up a short design doc for specifying sidecars in Tekton. Available here.
It doesn't address the issue of enforcing a sidecar lifecycle[1] at the moment. I've been skimming through the k8s codebase looking for the spot where the container termination flow is implemented and it looks as though the precise implementation of the grace period is delegated to the container runtime.
[1] https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods