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

Adding possibility to configure multiple service accounts for different tasks #902

Merged
merged 1 commit into from
Jun 17, 2019
Merged

Adding possibility to configure multiple service accounts for different tasks #902

merged 1 commit into from
Jun 17, 2019

Conversation

cezkuj
Copy link
Contributor

@cezkuj cezkuj commented May 23, 2019

Changes

The pipeline specification allows multiple different service accounts for tasks so that different task can use the right service account.
E.g. build task may need different privileges than deploy task

Fixes

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide
for more details.

Release Notes

Adding possibility to configure multiple service accounts for different tasks

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label May 23, 2019
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 23, 2019
@dibyom
Copy link
Member

dibyom commented May 23, 2019

/ok-to-test

@tekton-robot tekton-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 23, 2019
Gopkg.lock Outdated
@@ -22,7 +22,7 @@
version = "v0.2.0"

[[projects]]
digest = "1:355d491068cd888a3725d68cd09681a49251d6d8e3cb49120bf6b83a86c7ee0f"
digest = "1:c7ec3a8daf56c9d7c4bb36f498f6db3f8c339b1142300dcd4328950574f91c6f"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was updating this file intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was updated by hack/update-deps.sh (dep ensure). First version of PR didn't have that change and failed on integration test(please see Prow history).

@cezkuj
Copy link
Contributor Author

cezkuj commented May 25, 2019

/assign @dlorenc

@dlorenc
Copy link
Contributor

dlorenc commented May 25, 2019

In general this makes sense to me, but given it's an API change we should probably have another reviewer look.

My reasoning for why this would make sense:

  • Tasks within a pipeline may require access to different sets of resources, requiring different credentials. The principle of least-privilege would ask that Tasks get the minimum access they need, rather than the "highest-common-denominator".
  • Some Tasks may be authored in-house while others are reused from something like our catalog. Users may feel comfortable offering higher levels of access to tasks that they authored.

@dlorenc
Copy link
Contributor

dlorenc commented May 25, 2019

cc @bobcatfish @imjasonh to give the second sign off for an API review

@vdemeester
Copy link
Member

Same as @dlorenc, make sense to me ; mainly though of the first point, aka least-privilege 👼

@bobcatfish
Copy link
Collaborator

Thanks for including the docs in the PR @cezkuj and welcome to the project!!! ❤️

In general this makes sense to me, but given it's an API change we should probably have another reviewer look.

I agree in general with being able to specify service accounts at the level of the Tasks within a Pipeline (and possibly also at the level of the PipelineResources, but that's another story :D).

However I don't think we should put this in the Pipeline though: right now service accounts are considered runtime information and are included in the PipelineRun and TaskRun specs - I think if we want to add task specific service accounts, we should do that in the PipelineRun. A couple ideas how we could do that:

We could have a section for config specific to each task:

kind: PipelineRun
...
spec:
  pipelineRef:
    name: demo-pipeline
  serviceAccount: 'default'
  tasks:
  ...
  - name: source-repo
    serviceAccount: my-special-service-account

Or we could have a serviceAccount section:

kind: PipelineRun
...
spec:
  pipelineRef:
    name: demo-pipeline
  serviceAccount: 'default'
  serviceAccounts:
  ...
  - taskName: source-repo
    serviceAccount: my-special-service-account

What do you think @vdemeester @dlorenc @imjasonh ?

@bobcatfish
Copy link
Collaborator

/hold

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 28, 2019
@bobcatfish
Copy link
Collaborator

bobcatfish commented May 28, 2019

(Adding this to the WG agenda tomorrow in case folks want to discuss in person)

@vdemeester
Copy link
Member

oh yeah, definitely on PipelineRun 👍
@bobcatfish one question on your 2nd examples : having serviceAccounts would allow us to have multiple service accounts on each tasks ?

@bobcatfish
Copy link
Collaborator

@bobcatfish one question on your 2nd examples : having serviceAccounts would allow us to have multiple service accounts on each tasks ?

Hm i don't think so - I'm not sure if that would work with our current design 🤔

The only difference b/w the two examples is whether the top level thing is called tasks and each section is about configuration for tasks (which would assume we would want to put other task level info here later? maybe planning too far ahead, not sure what that would be ... 😅 ) and the other example has the top level thing called serviceAccounts instead and is just about serviceAccounts <-- probably simpler

@cezkuj
Copy link
Contributor Author

cezkuj commented May 28, 2019

Hmm, I see some reasoning behind moving it to PipelineRun. I would definitely go with serviceAccounts way as it seems more obvious for me. I will try to join WG tomorrow in case of further discussion.

@bobcatfish
Copy link
Collaborator

Didn't end up having time to discuss in the WG - I think go ahead with the serviceAccounts design or something similar @cezkuj ! If you want more discussion you could create a design doc, but I think it's a small enough change that we could just continue to discuss in the PR.

@cezkuj
Copy link
Contributor Author

cezkuj commented May 30, 2019

Updated PR with serviceAccounts implementation. Wasn't sure if taskName in serviceAccounts should refer to Task or PipelineTask - I've chosen Task. As a side effect of update-deps.sh LICENSE got also updated - not sure if this is wanted.

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great @cezkuj !! Thanks for your patience getting this reviewed 🙏

Since this changes the interface (#906), @vdemeester @dlorenc @imjasonh what do you think of this interface in PipelineRuns for specifying service accounts per task:

spec:
  serviceAccount: sa-1
  serviceAccounts:
    - taskName: build-task
      serviceAccount: sa-for-build

serviceAccounts:
- taskName: build-task
serviceAccount: sa-for-build
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this interface looks great! 👍

@@ -94,6 +94,15 @@ that is in the
[namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
of the `TaskRun` resource object.

There is also possibility to configure service account for concrete `Task`, overriding `ServiceAccount` set in `PipelineRun`, for example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would be good to be clear that the taskName below is the name of the task within the Pipeline, vs. the Task crd.

maybe you could just add a bit more to the example, e.g. something like:

For example with this serviceAccount configuration:

spec:
  serviceAccount: sa-1
  serviceAccounts:
    - taskName: build-task
      serviceAccount: sa-for-build

If used with this Pipeline, test-task will use the ServiceAccount sa-1, while build-task will use sa-for-build.

kind: Pipeline
spec:
  tasks:
    - name: build-task
      taskRef:
        name: build-push
  tasks:
    - name: test-task
      taskRef:
        name: test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, TBH, as far as I see I've implemented it to refer to Task crd. Now it seems less obvious to me why I'd go this way (plus it seems obvious for you to go with referring PipelineTask ). I'll change that and update docs as you've mentioned. Thanks for review!:)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to PipelineTask way and extended docs. Please take a look once again. :)

test/builder/pipeline.go Show resolved Hide resolved
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bobcatfish SGTM 👼

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cezkuj, dibyom, vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 14, 2019
…nt tasks

The pipeline specification allows multiple different service accounts for tasks so that different task can use the right service account.
E.g. build task may need different privileges than deploy task

Fixes
 - #777
@cezkuj
Copy link
Contributor Author

cezkuj commented Jun 15, 2019

/retest

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @cezkuj !!! 🙏

/hold cancel
/lgtm
/meow space

tasks:
- name: test-task
taskRef:
name: test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for adding this!

@tekton-robot
Copy link
Collaborator

@bobcatfish: cat image

In response to this:

Looks great, thanks @cezkuj !!! 🙏

/hold cancel
/lgtm
/meow space

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 17, 2019
@tekton-robot tekton-robot merged commit b6b2b6a into tektoncd:master Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants