Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sidecars #135

Closed
michaelsauter opened this issue Aug 10, 2021 · 2 comments · Fixed by #210
Closed

Support sidecars #135

michaelsauter opened this issue Aug 10, 2021 · 2 comments · Fixed by #210
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@michaelsauter
Copy link
Member

Tekton tasks may specify sidecars, see https://tekton.dev/vault/pipelines-v0.16.3/tasks/#specifying-sidecars. One use case for sidecars is to run a database for use with integration tests. To support this, our builder tasks (ods-build-go and friends) would need to be able to run a sidecar.

However, it seems like sidecars cannot be configured from a pipeline, only from within a task. This is problematic as we don't want to run a sidecar all the time, nor do we want that every user who wants to use a sidecar needs to create a custom task.

One idea I have is to automatically generate a "sidecar companion task": based on ods-build-go, generate a ods-build-go-with-sidecar task. This task also has a few parameters which allow to specify the image to use and the script to execute.

Other ideas?

FYI @felipecruz91 @renedupont

@michaelsauter michaelsauter added the question Further information is requested label Aug 10, 2021
@felipecruz91
Copy link
Contributor

felipecruz91 commented Aug 10, 2021

This is problematic as we don't want to run a sidecar all the time, nor do we want that every user who wants to use a sidecar needs to create a custom task.

Fully agree. In my view ods-pipeline should provide an additional task with support for sidecar containers.

One idea I have is to automatically generate a "sidecar companion task"

Yes, I guess we have no other option at the moment. The only drawback I see for now is maintainability (we'll now have twice the number of tasks per every builder task).

Perhaps you can elaborate a bit more on how to automatically generate the task? I'd like to have some make command that injects the sidecar container in a list of predefined tasks and the tasks generated (manifests) are then applied to the cluster, so we don't necessarily have to create them manually one by one.

@michaelsauter
Copy link
Member Author

The idea would be:

  1. Read the normal builder task from cluster
  2. Inject the sidecar and additional parameters
  3. Install the task with the sidecar in the cluster

That way we do not need to maintain two tasks. However the tests should verify that the sidecar works as expected.

Example:

Original task:

apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
  name: ods-build-go
spec:
  description: Builds Go (module) applications.
  params:
    - name: enable-cgo
      description: Whether to enable CGO. When not enabled the build will set `CGO_ENABLED=0`.
      type: string
      default: "false"
  steps:
    - name: build-go-binary
      image: build/package/Dockerfile.go-toolset
      resources: {}
      script: go build
      workingDir: $(workspaces.source.path)
  workspaces:
    - name: source

Modified task with sidecar:

apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
  name: ods-build-go
spec:
  description: Builds Go (module) applications.
  params:
    - name: enable-cgo
      description: Whether to enable CGO. When not enabled the build will set `CGO_ENABLED=0`.
      type: string
      default: "false"
    - name: sidecar-image
      description: Image to use for sidecar
      type: string
    - name: sidecar-script
      description: Image to use for sidecar
      type: string
      default: ''
  steps:
    - name: build-go-binary
      image: build/package/Dockerfile.go-toolset
      resources: {}
      script: go build
      workingDir: $(workspaces.source.path)
  sidecars:
  - image: $(params.sidecar-image)
    name: sidecar
    script: $(params.sidecar-script)
  workspaces:
    - name: source

@michaelsauter michaelsauter added this to the 0.2.0 milestone Aug 10, 2021
michaelsauter added a commit that referenced this issue Sep 15, 2021
The sidecar variants are the exact same task, with the addition of one
sidecar - the image for this sidecar needs to be specified.

Closes #135.
@michaelsauter michaelsauter modified the milestones: 0.2.0, 0.1.0 Sep 16, 2021
@michaelsauter michaelsauter self-assigned this Sep 16, 2021
@michaelsauter michaelsauter added enhancement New feature or request and removed question Further information is requested labels Sep 16, 2021
michaelsauter added a commit that referenced this issue Sep 17, 2021
The sidecar variants are the exact same task, with the addition of one
sidecar - the image for this sidecar needs to be specified.

Closes #135.
michaelsauter added a commit that referenced this issue Sep 17, 2021
The sidecar variants are the exact same task, with the addition of one
sidecar - the image for this sidecar needs to be specified.

Closes #135.
This was referenced Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants