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

Update auto deploy to be runnable on kubeflow-ci. #294

Merged
merged 12 commits into from
Jan 30, 2019
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):
gabrielwen marked this conversation as resolved.
Show resolved Hide resolved
# 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