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

Documentations for using tekton as agent in prowjob #1187

Closed
yfei1 opened this issue Aug 13, 2019 · 7 comments
Closed

Documentations for using tekton as agent in prowjob #1187

yfei1 opened this issue Aug 13, 2019 · 7 comments
Assignees
Labels
kind/documentation Categorizes issue or PR as related to documentation.

Comments

@yfei1
Copy link

yfei1 commented Aug 13, 2019

Expected Behavior

I'm not sure if this is a Prow or Tekton related issue. I was working on migrating a CI pipeline from Google Cloud Build to Prow. However, it seems like the native Kubernetes agent does not support running build/test sequentially in a pipelined way. I looked into api.ProwJob's source code and found there is a tekton controller defined in this file, yet it seems like we don't have documentations for using tekton-pipeline in Prow yet.

Also, I believe using tekton-pipeline as agent in a prowjob may require having tekton being deployed somewhere. Could you possibly point out some resources/examples I could look into to setup tekton along with my prow deployment? Thank!

Actual Behavior

@vdemeester vdemeester added the kind/documentation Categorizes issue or PR as related to documentation. label Aug 13, 2019
@vdemeester
Copy link
Member

@yfei1 I would say it might be more a prow issue but I feel we could also document it here (or at least on tekton.dev)

@yfei1
Copy link
Author

yfei1 commented Aug 13, 2019

@yfei1 I would say it might be more a prow issue but I feel we could also document it here (or at least on tekton.dev)

Thanks for your prompt reply! Could you point out some resources that I could look into for using tekton with prow?

@bobcatfish
Copy link
Collaborator

In the context of #922 I got Prow + Pipelines up and running for my own repo (thanks to @JoelSpeed 's notes in kubernetes/test-infra#13874 (comment) and some help from @krzyzacy + @BenTheElder !!), so I'll take this on and document how to get it to work!

bobcatfish added a commit to bobcatfish/plumbing that referenced this issue Aug 19, 2019
A step toward tektoncd/pipeline#922 !

This commit adds configuration and supporting docs to get Prow to
execute a simple Pipeline on every pull request to the plumbing repo.

I am also working on docs in the Prow repo
(for kubernetes/test-infra#13874 and
tektoncd/pipeline#1187) to explain how
one could put this all together from scratch.

One important caveat is that we were previously using the Tekton
installation in this cluster to do manual releases, and we were keeping
our release configuration up to date with the latest version of Tekton
Pipelines. Because of kubernetes/test-infra#13948
the newest version we can use with Prow is v0.3.1 so we need to keep our
release configs in sync with this for now ( attn folks doing releases
@vdemeester @a-roberts @mnuttall - the next thing I want to do is add
release automation via Prow so hopefully this won't impact you for
long!)

Note I have already manually applied this configuration to the cluster 🙏
tekton-robot pushed a commit to tektoncd/plumbing that referenced this issue Aug 20, 2019
A step toward tektoncd/pipeline#922 !

This commit adds configuration and supporting docs to get Prow to
execute a simple Pipeline on every pull request to the plumbing repo.

I am also working on docs in the Prow repo
(for kubernetes/test-infra#13874 and
tektoncd/pipeline#1187) to explain how
one could put this all together from scratch.

One important caveat is that we were previously using the Tekton
installation in this cluster to do manual releases, and we were keeping
our release configuration up to date with the latest version of Tekton
Pipelines. Because of kubernetes/test-infra#13948
the newest version we can use with Prow is v0.3.1 so we need to keep our
release configs in sync with this for now ( attn folks doing releases
@vdemeester @a-roberts @mnuttall - the next thing I want to do is add
release automation via Prow so hopefully this won't impact you for
long!)

Note I have already manually applied this configuration to the cluster 🙏
@bobcatfish bobcatfish modified the milestones: Pipelines 0.9 🐱, Pipelines 1.1 / Post-beta 🐱 Oct 30, 2019
@bobcatfish
Copy link
Collaborator

I think at this point it would make sense for this issue to live in the Prow repo only so I'll close this one. Also anyone should feel free to pickup where I left off with kubernetes/test-infra#13974 🙏

@noahkawasakigoogle
Copy link

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

@masseybradley
Copy link

masseybradley commented Nov 16, 2022

This is an example prow config for a tekton job:

presubmits:
  org/repo:
  - name: pr-build
    agent: tekton-pipeline
    always_run: true
    context: pr-build
    rerun_command: /test this
    trigger: (?m)^/test( all| this),?(\s+|$)
    pipeline_run_spec:
      trigger:
        type: manual
      pipelineRef:
        name: example
      resources:
      - name: source
        resourceRef:
          name: PROW_IMPLICIT_GIT_REF
      params:
      - name: args
        value:
          - "-a"
          - "-l"
          - "-F"
      workspaces:
      - name: workspace
        emptydir: {}
      - name: github-token
        secret:
          secretName: github-token

With an example tekton pipeline and task:

apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: example
  namespace: test-pods
spec:
  params:
  - name: REPO_OWNER
    type: string
  - default:
    - --help
    name: args
    type: array
  resources:
  - name: source
    type: git
  tasks:
  - name: example
    params:
    - name: args
      value:
      - $(params.args)
    - name: REPO_OWNER
      value: $(params.REPO_OWNER)
    resources:
      inputs:
      - name: source
        resource: source
    taskRef:
      kind: Task
      name: example
    workspaces:
    - name: workspace
      workspace: workspace
    - name: github-token
      workspace: github-token
  workspaces:
  - name: workspace
  - name: github-token
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: example
  namespace: test-pods
spec:
  description: This is an example task with args.
  params:
  - default:
    - --help
    description: extra args that needs to be appended
    name: args
    type: array
  - default: ""
    name: REPO_OWNER
    type: string
  resources:
    inputs:
    - name: source
      type: git
  stepTemplate:
    env:
    - name: REPO_OWNER
      value: $(params.REPO_OWNER)
    name: ""
    resources: {}
  steps:
  - args:
    - $(params.args)
    command:
    - ls
    image: ubuntu
    name: example
    resources: {}
    workingDir: $(workspaces.workspace.path)/source
  workspaces:
  - mountPath: /workspace
    name: workspace
  - mountPath: /var/run/secrets/github
    name: github-token

... using tekton v0.36.0, prow v20220705-20e880da9b, and prow pipeline. Need to use the legacy prowjob CRD (pipeline_run_spec doesn't handle passing arrays of args to tekton using the CRD). The github secret in the test-pods namespace (installation done using a modified starter-gcs.yaml) is an annotated basic-auth secret which tekton uses to clone repos and the github-token secret contains github app credentials (can be mounted in the tekton task and used for e.g. peribolos):

apiVersion: v1
data:
  password: <bot_personal_access_token>
  username: <bot>
kind: Secret
metadata:
  annotations:
    tekton.dev/git-0: https://github.com
  name: github
  namespace: test-pods
type: kubernetes.io/basic-auth

@qaifshaikh
Copy link

@masseybradley if you attach the github ssh secret to the service account you don't have to attach the secret everywhere 😄
Also, I've tried it with v20230111-cd1b3caf9c and it works quite well since that added the v1beta1 support for tekton
kubernetes-sigs/prow#44 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation.
Projects
None yet
Development

No branches or pull requests

8 participants