-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Provide a way to specify default service accounts #1227
Conversation
The following is the coverage report on pkg/.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
/cc @bobcatfish @imjasonh
@vdemeester @bobcatfish does it make sense to implement the same for |
b2308d7
to
f80266a
Compare
The following is the coverage report on pkg/.
|
I would think so yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this @sthaha and thanks for your patience! 🙏 A few requests:
- Can we add some docs on how to configure this? Maybe at https://github.com/tektoncd/pipeline/blob/master/docs/install.md#configuring-tekton-pipelines
- Can we add a test that ensures that the
serviceAccount
andserviceAccounts
fields will override the configured default? (https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md#service-accounts) Looking at the way you implemented it, I bet it will work, but just to be sure :) (could be a reconciler test, or an end to end test, or even an example) - Can we update https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md#service-account and https://github.com/tektoncd/pipeline/blob/master/docs/taskruns.md#service-account to indicate that the service account used when those fields aren't configured won't necessarily be the
default
account
Before this change, if there was no serviceAccount
or serviceAccounts
specified in a PipelineRun
or a TaskRun
, I could be reasonably sure that the service account default
was used, but that is no longer completely obvious.. And if the configuration of the controller was changed, I wouldn't be able to tell from looking at a previous Run
which service account was used. I wonder if it would make sense to include this in the status
field? I'm not 100% sure this is a good idea tho - maybe we can open a follow up issue and discuss? Or wait to see if ppl actually care (curious what you think @imjasonh @vdemeester )
(The coverage reporting seems a bit odd, opened #1248)
@@ -30,17 +30,20 @@ const ( | |||
DefaultTimeoutMinutes = 60 | |||
NoTimeoutDuration = 0 * time.Minute | |||
defaultTimeoutMinutesKey = "default-timeout-minutes" | |||
defaultServiceAccountKey = "default-service-account" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused why in config/config-defaults.yaml
the default service account is default
, but if that file isn't use, the default will be default-service-account
- would it make sense to use default
in both cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobcatfish default-service-account
is the "config" key to get the value for the default-service-account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobcatfish like @vdemeester mentioned, defaultServiceAccountKey
(default-service-account
) refers to the key
part of the configmap e.g.
data:
default-service-account: tekton
which if unspecified would spawn the pods with the default
ServiceAccount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah whoops, thanks for the explanation!
👍 will do
Nice! didn't think of this test 🤗
👍
I agree that this can be taken up as a follow up issue. On a related note, would |
I'm not sure! I feel like the |
IIUC, the |
This requires the test to
I was looking for a precedence (may be in the case of |
f80266a
to
bdf371b
Compare
The following is the coverage report on pkg/.
|
Hey @sthaha ! probably the easiest way would be to add a reconciler level test. For example this test case is making sure the right service account is used: pipeline/pkg/reconciler/taskrun/taskrun_test.go Lines 460 to 491 in eb6edee
pipeline/pkg/reconciler/taskrun/taskrun_test.go Lines 1050 to 1061 in eb6edee
It looks like the reconciler that this test instantiates passes a config map watcher into the reconciler, so i think if you use those fake kube clients + configure a config map, the test reconciler would use it: pipeline/pkg/reconciler/taskrun/taskrun_test.go Lines 256 to 273 in eb6edee
So what I would do is probably make a completely new test function, copying a lot of the body of the Run function from the test I linked above. (Sorry writing reconciler tests is kind of tedious!!) |
This PR allows defaults service-account (configurable though the configmap) to be set when none is specified in a PipelineRun. Fixes: tektoncd#1213 Signed-off-by: Sunil Thaha <[email protected]>
bdf371b
to
9d96e7b
Compare
} | ||
|
||
defaultSAName := "pipelines" | ||
defaultCfg := &config.Config{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobcatfish @vdemeester Does this suffice? Has 2 tests
- verifies that default service account specified in defaults is used
- verifies that if SA is set (
test-sa
) then that will be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes 😻 We may want to refactor some of this, but I think that's the job of a follow-up
The following is the coverage report on pkg/.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold
^^ to let @bobcatfish review 👼
} | ||
|
||
defaultSAName := "pipelines" | ||
defaultCfg := &config.Config{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes 😻 We may want to refactor some of this, but I think that's the job of a follow-up
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sthaha, 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 |
/hold cancel |
This PR allows defaults service-account (configurable though the configmap)
to be set when none is specified in a PipelineRun.
Fixes: #1213
Signed-off-by: Sunil Thaha [email protected]
Changes
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.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task and TaskRun to build and release this image
Reviewer Notes
If API changes
are included, additive changes
must be approved by at least two OWNERS
and backwards incompatible changes
must be approved by more than 50% of the OWNERS,
and they must first be added
in a backwards compatible way.
Release Notes