From ae2e39f2305830f3e458ea02afae388f7458d402 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 13:27:43 -0800 Subject: [PATCH 01/12] add init.sh --- test-infra/auto-deploy/init.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test-infra/auto-deploy/init.sh diff --git a/test-infra/auto-deploy/init.sh b/test-infra/auto-deploy/init.sh new file mode 100644 index 000000000..44479167e --- /dev/null +++ b/test-infra/auto-deploy/init.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -ex + +# Deployment configs. +SRC_DIR=$1 +REPO_OWNER=$2 +PROJECT=$3 +WORKER_CLUSTER=$4 + +# Check out fresh copy of KF and deployment workflow. +# TODO(gabrielwen): Need to make a seperate workflow to snapshot repos. +/usr/local/bin/checkout.sh ${SRC_DIR} ${REPO_OWNER} kubeflow +git clone --single-branch --branch version-snapshot \ + https://github.com/gabrielwen/testing.git ${SRC_DIR}/${REPO_OWNER}/testing +# /usr/local/bin/checkout.sh ${SRC_DIR} ${REPO_OWNER} testing + +# Initiate deployment workflow. +${SRC_DIR}/${REPO_OWNER}/testing/test-infra/auto-deploy/workflows.sh \ + ${SRC_DIR} \ + ${REPO_OWNER} \ + ${PROJECT} \ + ${WORKER_CLUSTER} From e72c757de96a3d2e57dfa873d613fef41721c31c Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 13:35:18 -0800 Subject: [PATCH 02/12] Move repo checkout to init.sh --- test-infra/auto-deploy/init.sh | 0 test-infra/auto-deploy/workflows.sh | 5 ----- 2 files changed, 5 deletions(-) mode change 100644 => 100755 test-infra/auto-deploy/init.sh diff --git a/test-infra/auto-deploy/init.sh b/test-infra/auto-deploy/init.sh old mode 100644 new mode 100755 diff --git a/test-infra/auto-deploy/workflows.sh b/test-infra/auto-deploy/workflows.sh index 9aab5e0ef..9eedd6b0d 100755 --- a/test-infra/auto-deploy/workflows.sh +++ b/test-infra/auto-deploy/workflows.sh @@ -10,11 +10,6 @@ REPO_OWNER=$2 PROJECT=$3 WORKER_CLUSTER=$4 -# Check out repos we need. -# TODO(gabrielwen): Need to make a seperate workflow to snapshot repos. -${SRC_DIR}/${REPO_OWNER}/testing/test-infra/auto-deploy/checkout.sh \ - ${SRC_DIR} ${REPO_OWNER} kubeflow - # Activate service account auth. export GOOGLE_APPLICATION_CREDENTIALS=/secret/gcp-credentials/key.json gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} From cde6415b59007ba0f69e9ade202c03cbaf342e37 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 13:38:31 -0800 Subject: [PATCH 03/12] Update Dockerfile to use init.sh --- test-infra/auto-deploy/Dockerfile | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/test-infra/auto-deploy/Dockerfile b/test-infra/auto-deploy/Dockerfile index e4427ca8e..8a62af7cc 100644 --- a/test-infra/auto-deploy/Dockerfile +++ b/test-infra/auto-deploy/Dockerfile @@ -153,17 +153,11 @@ RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.13.0/ # Work around for https://github.com/ksonnet/ksonnet/issues/298 ENV USER root -# Deployment related configs. -ARG SRC_DIR=/src -ARG REPO_OWNER=kubeflow -ARG PROJECT=kubeflow-ci -ARG WORKER_CLUSTER=kubeflow-testing - -# Check out a fresh copy of testing repo and use workflows in it. -RUN mkdir -p ${SRC_DIR}/${REPO_OWNER} -RUN git clone https://github.com/${REPO_OWNER}/testing.git $SRC_DIR/${REPO_OWNER}/testing - -ENV PYTHONPATH ${SRC_DIR}/${REPO_OWNER}/testing/py - -ENTRYPOINT ["${SRC_DIR}/${REPO_OWNER}/testing/test-infra/auto-deploy/workflows.sh", \ - ${SRC_DIR}, ${REPO_OWNER}, ${WORKER_CLUSTER}] +# Purpose of init.sh is to have a script as kickstarter. This script is used to pull fresh copy from +# Github and run with them. +COPY checkout.sh /usr/local/bin +RUN chmod a+x /usr/local/bin/checkout.sh +COPY init.sh /usr/local/bin +RUN chmod a+x /usr/local/bin/init.sh + +ENTRYPOINT ["/usr/local/bin/init.sh"] From ca5ebb3e4d68ffab372ed267e0523bc61e402aea Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 13:39:36 -0800 Subject: [PATCH 04/12] Change image pull path --- test-infra/auto-deploy/deploy-cron.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-infra/auto-deploy/deploy-cron.yaml b/test-infra/auto-deploy/deploy-cron.yaml index 5f5f545fb..6145f47eb 100644 --- a/test-infra/auto-deploy/deploy-cron.yaml +++ b/test-infra/auto-deploy/deploy-cron.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - name: deploy-worker - image: gcr.io/gabrielwen-learning/deploy-worker:latest + image: gcr.io/kubeflow-ci/deploy-worker:latest volumeMounts: - name: gcp-credentials mountPath: "/secret/gcp-credentials" From 392c397e1d1c9c5a3e0d807c086ad324c88352b3 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 13:43:24 -0800 Subject: [PATCH 05/12] Add args to deploy config --- test-infra/auto-deploy/deploy-cron.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test-infra/auto-deploy/deploy-cron.yaml b/test-infra/auto-deploy/deploy-cron.yaml index 6145f47eb..bc657fa75 100644 --- a/test-infra/auto-deploy/deploy-cron.yaml +++ b/test-infra/auto-deploy/deploy-cron.yaml @@ -14,6 +14,11 @@ spec: containers: - name: deploy-worker image: gcr.io/kubeflow-ci/deploy-worker:latest + args: + - /src # SRC_DIR + - kubeflow # REPO_OWNER + - kubeflow-ci # PROJECT + - kubeflow-testing # WORKER_CLUSTER volumeMounts: - name: gcp-credentials mountPath: "/secret/gcp-credentials" From 073fb9a7e8857b87e7d5a9fe1293ee0b8cc7e6cc Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 14:07:46 -0800 Subject: [PATCH 06/12] Add PYTHONPATH --- test-infra/auto-deploy/init.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test-infra/auto-deploy/init.sh b/test-infra/auto-deploy/init.sh index 44479167e..8779a79b4 100755 --- a/test-infra/auto-deploy/init.sh +++ b/test-infra/auto-deploy/init.sh @@ -14,6 +14,9 @@ git clone --single-branch --branch version-snapshot \ https://github.com/gabrielwen/testing.git ${SRC_DIR}/${REPO_OWNER}/testing # /usr/local/bin/checkout.sh ${SRC_DIR} ${REPO_OWNER} testing +PYTHONPATH="${PYTHONPATH}:${SRC_DIR}/${REPO_OWNER}/testing/py" +export PYTHONPATH + # Initiate deployment workflow. ${SRC_DIR}/${REPO_OWNER}/testing/test-infra/auto-deploy/workflows.sh \ ${SRC_DIR} \ From fcabf7a3f4b015f9e26f49e5ce8781c2099b8d41 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 14:32:58 -0800 Subject: [PATCH 07/12] temp disable deployment deletion --- py/kubeflow/testing/create_kf_instance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/kubeflow/testing/create_kf_instance.py b/py/kubeflow/testing/create_kf_instance.py index 04c4cd92d..819d25f97 100644 --- a/py/kubeflow/testing/create_kf_instance.py +++ b/py/kubeflow/testing/create_kf_instance.py @@ -85,8 +85,8 @@ def main(): # pylint: disable=too-many-locals,too-many-statements # Clean up previous deployment. We are not able to run "kfctl delete all" # since we are not able to guarantee apps config in repository is up to date. util.run(["rm", "-rf", name], cwd=args.apps_dir) - util.run(["gcloud", "deployment-manager", "deployments", "delete", name, - "--project", args.project], cwd=args.apps_dir) + # util.run(["gcloud", "deployment-manager", "deployments", "delete", name, + # "--project", args.project], cwd=args.apps_dir) # Create a dummy kubeconfig in cronjob worker. util.run(["gcloud", "container", "clusters", "get-credentials", args.deployment_worker_cluster, From e4768dd089660635bad3610b4feb4601abf42645 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 14:45:15 -0800 Subject: [PATCH 08/12] add comment --- py/kubeflow/testing/create_kf_instance.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/kubeflow/testing/create_kf_instance.py b/py/kubeflow/testing/create_kf_instance.py index 819d25f97..91b05fb86 100644 --- a/py/kubeflow/testing/create_kf_instance.py +++ b/py/kubeflow/testing/create_kf_instance.py @@ -85,6 +85,10 @@ def main(): # pylint: disable=too-many-locals,too-many-statements # Clean up previous deployment. We are not able to run "kfctl delete all" # since we are not able to guarantee apps config in repository is up to date. util.run(["rm", "-rf", name], cwd=args.apps_dir) + # TODO(gabrielwen): + # 1. Is deployment deletion still needed? + # 2. If it is, figure out permission set up for it before uncomment lines + # below. # util.run(["gcloud", "deployment-manager", "deployments", "delete", name, # "--project", args.project], cwd=args.apps_dir) From f0b36e9a344e856cc1affc730c23f32e07a6a596 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Mon, 28 Jan 2019 14:48:02 -0800 Subject: [PATCH 09/12] update --- test-infra/auto-deploy/init.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test-infra/auto-deploy/init.sh b/test-infra/auto-deploy/init.sh index 8779a79b4..0a7968575 100755 --- a/test-infra/auto-deploy/init.sh +++ b/test-infra/auto-deploy/init.sh @@ -10,9 +10,7 @@ WORKER_CLUSTER=$4 # Check out fresh copy of KF and deployment workflow. # TODO(gabrielwen): Need to make a seperate workflow to snapshot repos. /usr/local/bin/checkout.sh ${SRC_DIR} ${REPO_OWNER} kubeflow -git clone --single-branch --branch version-snapshot \ - https://github.com/gabrielwen/testing.git ${SRC_DIR}/${REPO_OWNER}/testing -# /usr/local/bin/checkout.sh ${SRC_DIR} ${REPO_OWNER} testing +/usr/local/bin/checkout.sh ${SRC_DIR} ${REPO_OWNER} testing PYTHONPATH="${PYTHONPATH}:${SRC_DIR}/${REPO_OWNER}/testing/py" export PYTHONPATH From 703c61ccda523d9dc079e380970dce64cd650846 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Tue, 29 Jan 2019 10:48:37 -0800 Subject: [PATCH 10/12] create issue for deployment permission and deletion script --- py/kubeflow/testing/create_kf_instance.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/kubeflow/testing/create_kf_instance.py b/py/kubeflow/testing/create_kf_instance.py index 91b05fb86..11e1e737a 100644 --- a/py/kubeflow/testing/create_kf_instance.py +++ b/py/kubeflow/testing/create_kf_instance.py @@ -86,11 +86,11 @@ def main(): # pylint: disable=too-many-locals,too-many-statements # since we are not able to guarantee apps config in repository is up to date. util.run(["rm", "-rf", name], cwd=args.apps_dir) # TODO(gabrielwen): + # https://github.com/kubeflow/testing/issues/295 # 1. Is deployment deletion still needed? - # 2. If it is, figure out permission set up for it before uncomment lines - # below. - # util.run(["gcloud", "deployment-manager", "deployments", "delete", name, - # "--project", args.project], cwd=args.apps_dir) + # 2. If it is, figure out permission set up for it. + # 3. Should use + # https://github.com/kubeflow/kubeflow/blob/master/scripts/gke/delete_deployment.sh # Create a dummy kubeconfig in cronjob worker. util.run(["gcloud", "container", "clusters", "get-credentials", args.deployment_worker_cluster, From 5d757f082a85bb359580c594d5098c7ea457d224 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Tue, 29 Jan 2019 10:50:50 -0800 Subject: [PATCH 11/12] use command in yaml instead of args + ENTRYPOINT --- test-infra/auto-deploy/Dockerfile | 2 -- test-infra/auto-deploy/deploy-cron.yaml | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test-infra/auto-deploy/Dockerfile b/test-infra/auto-deploy/Dockerfile index 8a62af7cc..b2ae08d17 100644 --- a/test-infra/auto-deploy/Dockerfile +++ b/test-infra/auto-deploy/Dockerfile @@ -159,5 +159,3 @@ COPY checkout.sh /usr/local/bin RUN chmod a+x /usr/local/bin/checkout.sh COPY init.sh /usr/local/bin RUN chmod a+x /usr/local/bin/init.sh - -ENTRYPOINT ["/usr/local/bin/init.sh"] diff --git a/test-infra/auto-deploy/deploy-cron.yaml b/test-infra/auto-deploy/deploy-cron.yaml index bc657fa75..3660d8d01 100644 --- a/test-infra/auto-deploy/deploy-cron.yaml +++ b/test-infra/auto-deploy/deploy-cron.yaml @@ -14,7 +14,8 @@ spec: containers: - name: deploy-worker image: gcr.io/kubeflow-ci/deploy-worker:latest - args: + command: + - /usr/local/bin/init.sh - /src # SRC_DIR - kubeflow # REPO_OWNER - kubeflow-ci # PROJECT From 3918929c433eb6f38673015d757eb8cf2707c304 Mon Sep 17 00:00:00 2001 From: Gabriel Wen Date: Tue, 29 Jan 2019 11:03:07 -0800 Subject: [PATCH 12/12] change tag to live --- test-infra/auto-deploy/deploy-cron.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-infra/auto-deploy/deploy-cron.yaml b/test-infra/auto-deploy/deploy-cron.yaml index 3660d8d01..853c0b0d5 100644 --- a/test-infra/auto-deploy/deploy-cron.yaml +++ b/test-infra/auto-deploy/deploy-cron.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - name: deploy-worker - image: gcr.io/kubeflow-ci/deploy-worker:latest + image: gcr.io/kubeflow-ci/deploy-worker:live command: - /usr/local/bin/init.sh - /src # SRC_DIR