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

Add documentation for using Tekton with Prow 🙌 #13974

Closed
wants to merge 1 commit into from

Conversation

bobcatfish
Copy link
Contributor

This commit adds the beginning of some usage documentation about how to
get Tekton and Prow working. I think there's probably more to add but I hope this can
be a good starting point!

Please let me know if the docs or the examples should be in different locations, I basically just tried to guess and pick something but am happy to move things around!

I wouldn't have been able to do this without @JoelSpeed's guidance in
#13874 (comment)
Thanks @JoelSpeed!!! ❤️

I was able to follow along with these docs and get Tekton + Prow running
for tektoncd itself: tektoncd/plumbing#66 🎉

Fixes #13874 (and maybe tektoncd/pipeline#1187 as well?)

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 19, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @bobcatfish. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 19, 2019
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/prow Issues or PRs related to prow area/prow/bump Updates to the k8s prow cluster sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Aug 19, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bobcatfish
To complete the pull request process, please assign cjwagner
You can assign the PR to them by writing /assign @cjwagner in a comment when ready.

The full list of commands accepted by this bot can be found 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

@bobcatfish
Copy link
Contributor Author

Keywords which can automatically close issues and at(@) mentions are not allowed in commit messages.

I understand issue closing but I am curious why @-ing is not okay :O

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Aug 19, 2019
@stevekuznetsov
Copy link
Contributor

Whoever is on the other side of the at-mention will get a notification every time:

  • you push the commit
  • your commit is merged into a branch, including:
    a. when this PR merges
    b. when the commit is cherry-picked into other branches
    c. when commits move around in forks of the repo

It ends up being pretty spammy :)

For review
/assign @cjwagner @ccojocar

Copy link
Member

@ccojocar ccojocar left a comment

Choose a reason for hiding this comment

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

Thanks for writing this doc! I looks great! I just left a few comments. It would be nice if you could have a look at them.

@@ -0,0 +1,33 @@
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

There is already a deployment in pipeline_deployment.yaml. I am wondering wha's the reason to not reuse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/kubernetes/test-infra/blob/master/prow/cluster/pipeline_deployment.yaml uses some other configuration: a secret called build-cluster so in order to use it as is, these instructions would have to explain how to set that up - and since it's optional, I don't think they should? (or maybe by default folks should use --build-cluster=/etc/build-cluster/cluster? I dont actually know what this does 😅 )

Copy link
Member

Choose a reason for hiding this comment

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

That flag is for running the jobs in a different cluster.

I think it is too misleading to include these deployment files in the prow/cluster directory. With the exception of starter.yaml (which we should probably move) all of the files under prow/cluster are deployed to the prow.k8s.io instance, but the files you've added wouldn't work for our instance.

It looks like this is a more detailed version of prow/cmd/pipeline/dev.yaml. Consider updating that file or adding this one to that directory.

Copy link
Member

Choose a reason for hiding this comment

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

I see, it can be actually pointed to the same cluster. It's true there is an additional configuration step to set up that secret.

Maybe it shouldn't fail with an error if the provided file is empty/missing. Sounds like a warnings message and use the same cluster is more appropriate in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like this is a more detailed version of prow/cmd/pipeline/dev.yaml. Consider updating that file or adding this one to that directory.

Ah I didn't even see dev.yaml! For now I've moved these examples into cmd/pipeline and cmd/crier

@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

There is a deployment for crier in crier_deployment.yaml. I am wondering what's the reason to not reuse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to above comment about pipeline_deployment.yaml, https://github.com/kubernetes/test-infra/blob/master/prow/cluster/crier_deployment.yaml includes an optional job-config configmap

Copy link
Member

Choose a reason for hiding this comment

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

As with the pipeline controller, this change would prevent crier from working properly on out instance so including it in prow/cluster is kind of misleading.

If you want to add a set of deployment files for a Prow instance that only uses tekton, consider grouping those in a separate directory to make it clear what the purpose is and so that users know what components they actually need to deploy (e.g. sinker and at least one of hook, horologium, or the gerrit adapter will be needed to actually trigger jobs.)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see that in the docs you have the user first follow getting_started_deploy.md so hook, horologium, etc will already be deployed.

prow/tekton.md Outdated

```

### Install Tekton Pipelines
Copy link
Member

@ccojocar ccojocar Aug 20, 2019

Choose a reason for hiding this comment

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

I am not sure but I think this step needs to be before installing the controller because the controller expects the PipelineRun CRD to be already installed in order to be able to start watching it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kk i can try to make that more clear

trigger: # Required by versions 0.2.0 - v0.3.1 of Tekton Pipelines
type: manual
pipelineRef:
name: special-pipeline # Use the Tekton Pipeline called `special-pipeline`
Copy link
Member

@ccojocar ccojocar Aug 20, 2019

Choose a reason for hiding this comment

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

I think the serviceAccount needs also to be defined. It should be the Tekton's service account with the GitHub token linked to it. I am not sure that service account is used by default by the Tekton controller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be the Tekton's service account with the GitHub token linked to it.

Maybe you can explain more about what this service account would be doing? You can optionally provide a serviceAccount to a PipelineRun but that just makes it available to executing Tasks if they need it (e.g. to push to an image registry).

Re the GitHub token, if the PipelineRun was trying to push something to GitHub for example, if you wanted to use the PullRequest resource and push to GitHub from the Pipeline itself, you'd need to provide a secret in the PipelineResource

TL;DR it depends on what the PipelineRun is doing - I can add a link to the PipelineRun docs and try to make that more clear here.

I am not sure that service account is used by default by the Tekton controller.

The controller uses the tekton-pipelines-controller service account by default (https://github.com/tektoncd/pipeline/blob/master/config/controller.yaml#L28) - but pods that execute as part of a PipelineRun would use the default service account of the namespace by default, unless serviceAccount or serviceAccounts are specified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a link to the PipelineRun docs right below this and mentioned ServiceAccounts!

Copy link
Member

Choose a reason for hiding this comment

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

I mean this service account https://github.com/tektoncd/pipeline/blob/master/docs/auth.md#basic-authentication-git, but pointing to the doc is enough if someone needs to configure it. Thanks for adding that!

@bobcatfish
Copy link
Contributor Author

I made some changes, lemme know what you think @ccojocar ! Also let me know what you want to do about the differences between those example yaml files :S

Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

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

Thanks Christie!

@@ -0,0 +1,33 @@
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

That flag is for running the jobs in a different cluster.

I think it is too misleading to include these deployment files in the prow/cluster directory. With the exception of starter.yaml (which we should probably move) all of the files under prow/cluster are deployed to the prow.k8s.io instance, but the files you've added wouldn't work for our instance.

It looks like this is a more detailed version of prow/cmd/pipeline/dev.yaml. Consider updating that file or adding this one to that directory.

@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

As with the pipeline controller, this change would prevent crier from working properly on out instance so including it in prow/cluster is kind of misleading.

If you want to add a set of deployment files for a Prow instance that only uses tekton, consider grouping those in a separate directory to make it clear what the purpose is and so that users know what components they actually need to deploy (e.g. sinker and at least one of hook, horologium, or the gerrit adapter will be needed to actually trigger jobs.)

prow/tekton.md Outdated
**Warning**

Prow users may expect to see logs from their `PipelineRuns` be visible in
Gubernator, however this functionality is not supported yet, and logs must be
Copy link
Member

Choose a reason for hiding this comment

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

Gubernator is deprecated in favor of Spyglass. It might be more accurate to note that pipeline prowjobs cannot be decorated with the pod utilities so job logs, metadata, and artifacts are not uploaded to GCS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kk updated!

@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see that in the docs you have the user first follow getting_started_deploy.md so hook, horologium, etc will already be deployed.

skip_report: false
pipeline_run_spec: # Template for creation of the `PipelineRun`
trigger: # Required by versions 0.2.0 - v0.3.1 of Tekton Pipelines
type: manual
Copy link
Member

Choose a reason for hiding this comment

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

If this is required should we have the pipeline prow controller add it if it isn't present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that would work! even better tho would be to update the version of Pipelines that Prow is using tho - this field is deprecated

prow/tekton.md Outdated
rerun_command: "/run do-the-pipeline"
trigger: "(?m)^/run do-the-pipeline,?(\\s+|$)"
always_run: true
skip_report: false
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd omit the skip_report, rerun_command, and trigger fields. They aren't necessary if you are ok with using /test do-the-pipeline to trigger the job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kk!

prow/tekton.md Outdated
* `pipelineRef` - Refers to a
[`Pipeline`](#create-and-apply-pipelines-and-tasks) that must exist for the
`PipelineRun` to be able to execute
* [`PROW_IMPLICIT_GIT_REF`] - Using this special
Copy link
Member

Choose a reason for hiding this comment

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

It is probably worth noting that we also support PROW_EXTRA_GIT_REF_0, PROW_EXTRA_GIT_REF_1, etc. if the ProwJob specifies extraRefs e.g.

extra_refs:
- org: kubernetes
repo: org
base_ref: master

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for mentioning this, this saved my life when I went to use this for periodic jobs XD

prow/tekton.md Outdated
1. [Setting up Pipelines with Prow](#setting-up-pipelines-with-prow)
2. [Configuring a `tekton-pipeline` job](#configuring-a-tekton-pipeline-job)

**Warning**
Copy link
Member

Choose a reason for hiding this comment

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

The other caveat is that git pipelineresources are currently not garbage collected. (I think we can fix this by updating the pipelineresources with owner references after the pipelinerun is created.)

Copy link
Member

Choose a reason for hiding this comment

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

I implemented this initially in the controller and it worked well, but I was asked to remove it due to the multi-cluster build support. Referencing the ProwJob is problematic when the builds are executed in a different cluster but I don't see an issue with a reference to the PipelineRun.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a warning about this! Btw tektoncd/pipeline#544 is about this and it looks like this will be addressed in tektoncd/pipeline#872 (which was your request originally @cjwagner!) - you'd have to update Prow to be able to embed PipelineResources tho :)

@bobcatfish
Copy link
Contributor Author

Quick update: thanks for the detailed review @cjwagner + @ccojocar - I'm planning to come back and update the PR with your suggestions just haven't gotten a chance yet 🙏

This commit adds the beginning of some usage documentation about how to
get Tekton and Prow working.

I wouldn't have been able to do this without JoelSpeed's guidance in
kubernetes#13874 (comment)
Thanks JoelSpeed!!! ❤️

I was able to follow along with these docs and get Tekton + Prow running
for `tektoncd` itself: tektoncd/plumbing#66 🎉

This is being done for kubernetes#13874
@k8s-ci-robot k8s-ci-robot added the area/prow/crier Issues or PRs related to prow's crier component label Sep 19, 2019
@bobcatfish
Copy link
Contributor Author

Okay @cjwagner @ccojocar I finally came back to this (sorry for the delay! 🙏 ) and I think I've addressed all your feedback so far (I also added a periodic example), PTAL :D

@matthyx
Copy link
Contributor

matthyx commented Sep 20, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 20, 2019
Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

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

Looks good, I just have some minor suggestions.

- --github-workers=1
- --config-path=/etc/config/config.yaml
- --github-endpoint=http://ghproxy
- --github-endpoint=https://api.github.com
Copy link
Member

Choose a reason for hiding this comment

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

The instructions you provided don't include setting up ghproxy so the --github-endpoint flags will make every request fail on the first attempt. I'd suggest removing them both.

labels:
app: crier
spec:
# Using the service account defined in prow/cluster/pipeline_rbac.yaml
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Using the service account defined in prow/cluster/pipeline_rbac.yaml
# Using the service account defined in prow/cluster/crier_rbac.yaml

## Setting up Pipelines with Prow

1. [Setup and configure Prow itself](getting_started_deploy.md)
2. [Install Tekton Pipelines](#install-tekton)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
2. [Install Tekton Pipelines](#install-tekton)
2. [Install Tekton Pipelines](#install-tekton-pipelines)

@matthyx
Copy link
Contributor

matthyx commented Nov 14, 2019

@bobcatfish will you have time to address these nits? It's too bad to delay merging for small stuff...

can start, and in order to be able to execute [Tekton Pipelines](https://github.com/tektoncd/pipeline,
you also need to install and setup Tekton Pipelines itself.

[Prow is currently compatible with versions 0.2.0 - 0.3.1 of Tekton Pipelines](https://github.com/kubernetes/test-infra/issues/13948)
Copy link

Choose a reason for hiding this comment

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

0.8.0 are supported now

@bobcatfish
Copy link
Contributor Author

Just in case I ever get back to this, prow supports tekton pipelines 0.10.1 now #16099

(sorry @matthyx !!! im gonna try to get this in asap 😭 totally happy if someone else is able to take this over tho!)

@bobcatfish
Copy link
Contributor Author

At this rate I don't think I'm getting back to this anytime soon :( Hopefully what I wrote can still be helpful if someone else can take this on later!

@noahkawasakigoogle
Copy link

Did any documentation on Prow + Tekton ever happen? I couldnt find anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/prow/bump Updates to the k8s prow cluster area/prow/crier Issues or PRs related to prow's crier component area/prow Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

Documentations for using tekton with Prow
8 participants