Skip to content

Commit

Permalink
Update auto deploy to be runnable on kubeflow-ci. (kubeflow#294)
Browse files Browse the repository at this point in the history
* add init.sh

* Move repo checkout to init.sh

* Update Dockerfile to use init.sh

* Change image pull path

* Add args to deploy config

* Add PYTHONPATH

* temp disable deployment deletion

* add comment

* update

* create issue for deployment permission and deletion script

* use command in yaml instead of args + ENTRYPOINT

* change tag to live
  • Loading branch information
gabrielwen authored and k8s-ci-robot committed Jan 30, 2019
1 parent b0e09d8 commit 8e3b8f7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
8 changes: 6 additions & 2 deletions py/kubeflow/testing/create_kf_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ 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)
# 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.
# 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,
Expand Down
20 changes: 6 additions & 14 deletions test-infra/auto-deploy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,9 @@ 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
8 changes: 7 additions & 1 deletion test-infra/auto-deploy/deploy-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ spec:
spec:
containers:
- name: deploy-worker
image: gcr.io/gabrielwen-learning/deploy-worker:latest
image: gcr.io/kubeflow-ci/deploy-worker:live
command:
- /usr/local/bin/init.sh
- /src # SRC_DIR
- kubeflow # REPO_OWNER
- kubeflow-ci # PROJECT
- kubeflow-testing # WORKER_CLUSTER
volumeMounts:
- name: gcp-credentials
mountPath: "/secret/gcp-credentials"
Expand Down
23 changes: 23 additions & 0 deletions test-infra/auto-deploy/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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
/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} \
${REPO_OWNER} \
${PROJECT} \
${WORKER_CLUSTER}
5 changes: 0 additions & 5 deletions test-infra/auto-deploy/workflows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 8e3b8f7

Please sign in to comment.