Skip to content

Commit

Permalink
Create a python script to autogenerate PipelineRun's for all kubeflow…
Browse files Browse the repository at this point in the history
… applications

* Define a config file to list
  i) Relevant information about each application to build
     e.g the location of its source, the location of its kustomize manifest
 ii) The versions (i.e. branches) of the various repositories to build from

* Create a python script that takes the cross product of applications and
  versions and creates a tekton PipelineRun to build the docker image
  and update the manifest.

* Fix a bug in update_manifests with image_name not being set.
Related to kubeflow#450: Continuous delivery of Kubeflow applications

Here are some autogenerated PRs updating the manifests

  * kubeflow/manifests#697
  * kubeflow/manifests#696

* Fix email of kubeflow bot to pass CLA check.

  * Fix kubeflow#557
  • Loading branch information
Jeremy Lewi committed Jan 8, 2020
1 parent 768a4d0 commit 48e6201
Show file tree
Hide file tree
Showing 9 changed files with 628 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ confidence=
# modules when running locally vs in our test infrastructure. It looks like what counts
# as third party might vary.
#
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,missing-docstring,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,relative-import,invalid-name,bad-continuation,no-member,locally-disabled,fixme,import-error,too-many-locals,wrong-import-order,no-self-use,too-many-statements
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,missing-docstring,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,relative-import,invalid-name,bad-continuation,no-member,locally-disabled,fixme,import-error,too-many-locals,wrong-import-order,no-self-use,too-many-statements,logging-fstring-interpolation


[REPORTS]
Expand Down
48 changes: 46 additions & 2 deletions apps-cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ and open PRs to update Kubeflow kustomize manifests to use the newly built image

* The kubeflow-bot GitHub account is used to create the PRs

### Adding Applications to continuous delivery

Here are instructions for adding an application for continous delivery

* You should add an entry to [applications.yaml](applications.yaml) for that application

* Set the parameters as needed for that application

### Defining a New Version/Release For Applications

* The versions in [applications.yaml](applications.yaml) specify the different
releases e.g. master, v0.X, v0.Y, etc... at which to build the applications

* For every version we define

* **tag** This is a label like "vmaster" or "v0.X.1" that will be used to tag the images
* The source repos and corresponding branch from which to build the images

* Each time the create-runs script is run it will create a pipeline run that uses the tip
of that branch for that source

* A repo for kubeflow manifests that specifies the branch of the kustomize package to update


### Run a pipeline

To update a specific application
Expand All @@ -59,10 +83,30 @@ To update a specific application
* Set the Tekton PipelineRun parameters and resources as needed to build your
application at the desired commit

1. Run it
1. Generate the pipeline runs for the latest commits

```
kubectl create -f ${PIPELINERUN_FILE}
KUBEFLOW_TESTING=<Path where kubeflow/testing is checked out>
OUTPUT_DIR=<Directory to write the PipelineRuns YAML files>
SRC_DIR=<Directory where source repos should be checked out>
CONFIG=${KUBEFLOW_TESTING}/apps-cd/applications.yaml
TEMPLATE=${KUBEFLOW_TESTING}/apps-cd/runs/app-pipeline.template.yaml
cd ${KUBEFLOW_TESTING}/py
python3 -m kubeflow.testing.cd.update_kf_apps create-runs \
--config=${CONFIG} \
--output_dir=${OUTPUT_DIR} \
--src_dir=${SRC_DIR} \
--template=${TEMPLATE}
```

* This will create a YAML file for every (application, version) combination

1. Submit PipelineRun's to the release cluster

```
kubectl create -f ${OUTPUT_DIR}
```

### Setting up a cluster to run the pipelines
Expand Down
100 changes: 100 additions & 0 deletions apps-cd/applications.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# This file contains the configuration for the Tekton pipelines
# To auto update Kubeflow applications
#
# Applications provides information about each application to build
# Note: Keep applications organized alphabetically by name.
applications:
- name: admission-webhook
params:
- name: "path_to_context"
value: "components/admission-webhook"
- name: "path_to_docker_file"
value: "components/admission-webhook/Dockerfile"
- name: "path_to_manifests_dir"
value: "admission-webhook/webhook/base"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/admission-webhook"
sourceRepo: kubeflow
- name: centraldashboard
params:
- name: "path_to_context"
value: "components/centraldashboard"
- name: "path_to_docker_file"
value: "components/centraldashboard/Dockerfile"
- name: "path_to_manifests_dir"
value: "common/centraldashboard/base"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/centraldashboard"
sourceRepo: kubeflow
- name: kfam
params:
- name: "path_to_context"
value: "components/access-management"
- name: "path_to_docker_file"
value: "components/acess-management/Dockerfile"
- name: "path_to_manifests_dir"
value: "profiles/base"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/kfam"
sourceRepo: kubeflow
- name: notebook-controller
params:
- name: "path_to_context"
value: "components/notebook-controller"
- name: "path_to_docker_file"
value: "components/notebook-controller/Dockerfile"
- name: "path_to_manifests_dir"
value: "jupyter/notebook-controller"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/notebook-controller"
# The name of the repo containing the source
sourceRepo: kubeflow
- name: notebook-webapp
params:
- name: "path_to_context"
value: "components/jupyter-web-app"
- name: "path_to_docker_file"
value: "components/jupyter-web-app/Dockerfile"
- name: "path_to_manifests_dir"
value: "jupyter/jupyter-web-app/base"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/jupyter-web-app"
# The name of the repo containing the source
sourceRepo: kubeflow
- name: profile-controller
params:
- name: "path_to_context"
value: "components/profile-controller"
- name: "path_to_docker_file"
value: "components/profile-controller/Dockerfile"
- name: "path_to_manifests_dir"
value: "profiles/base"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/profile-controller"
# The name of the repo containing the source
sourceRepo: kubeflow
# The versions to build the applications at
# Each version should consist of a list of repositories and the corresponding
# branch and a tag
versions:
# master should be the latest code built from all of the master branches
- name: master
# A tag to prefix image names with
tag: vmaster
repos:
- name: kubeflow
resourceSpec:
type: git
params:
- name: revision
value: master
- name: url
value: git@github.com:kubeflow/kubeflow.git
- name: manifests
resourceSpec:
type: git
params:
- name: revision
value: master
- name: url
value: git@github.com:kubeflow/manifests.git
61 changes: 61 additions & 0 deletions apps-cd/runs/app-pipeline.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is a template used for generating PipelineRuns for
# individual applications at specific commits.
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
# Generate a unique name for each run
generateName: ci-profile-controller-
spec:
pipelineRef:
name: ci-pipeline
params:
- name: "path_to_context"
value: "components/profile-controller"
- name: "path_to_docker_file"
value: "components/profile-controller/Dockerfile"
- name: "path_to_manifests_dir"
value: "profiles/base"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/profile-controller"
- name: "container_image"
value: "gcr.io/kubeflow-releasing/test-worker@sha256:35138a42b57160a078e802b7d69aec3c3e79a3e2e55518af7798275ebcc84d25"
resources:
# The git resources that will be used
- name: kubeflow
resourceSpec:
type: git
params:
- name: revision
value: "1795828"
- name: url
value: git@github.com:kubeflow/kubeflow.git
- name: manifests
resourceSpec:
type: git
params:
- name: revision
value: master
- name: url
value: git@github.com:kubeflow/manifests.git
- name: ci-tools
resourceSpec:
type: git
params:
# TODO(jlewi): Replace with kubeflw/testing master once the PR is merged
#
- name: revision
value: cicd
- name: url
value: git@github.com:jlewi/testing.git
#- name: revision
# value: master
#- name: url
# value: git@github.com:kubeflow/testing.git
# The image we want to build
- name: image
resourceSpec:
type: image
params:
- name: url
value: gcr.io/kubeflow-images-public/profile-controller:vmaster-g1795828
serviceAccountName: ci-pipeline-run-service-account
1 change: 1 addition & 0 deletions py/kubeflow/testing/cd/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

54 changes: 54 additions & 0 deletions py/kubeflow/testing/cd/test_data/notebook_controller.expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
# Generate a unique name for each run
generateName: cd-notebook-controller-1234abcd
spec:
pipelineRef:
name: ci-pipeline
params:
- name: "path_to_context"
value: "components/notebook-controller"
- name: "path_to_docker_file"
value: "components/notebook-controller/Dockerfile"
- name: "path_to_manifests_dir"
value: "jupyter/notebook-controller"
- name: "src_image_url"
value: "gcr.io/kubeflow-images-public/notebook-controller"
- name: "container_image"
value: "gcr.io/kubeflow-releasing/test-worker@sha256:35138a42b57160a078e802b7d69aec3c3e79a3e2e55518af7798275ebcc84d25"
resources:
# The git resources that will be used
- name: kubeflow
resourceSpec:
type: git
params:
- name: revision
value: "1234abcd"
- name: url
value: git@github.com:kubeflow/kubeflow.git
- name: manifests
resourceSpec:
type: git
params:
- name: revision
value: master
- name: url
value: git@github.com:kubeflow/manifests.git
# TODO(jlewi): Replace with kubeflw/kubeflow once the PR is checked in.
- name: ci-tools
resourceSpec:
type: git
params:
- name: revision
value: tekton
- name: url
value: git@github.com:jlewi/testing.git
# The image we want to build
- name: image
resourceSpec:
type: image
params:
- name: url
value: gcr.io/kubeflow-images-public/notebook-controller:vmaster-g1234abcd
serviceAccountName: ci-pipeline-run-service-account
Loading

0 comments on commit 48e6201

Please sign in to comment.