Skip to content

Commit

Permalink
Create a batch job to allow manual runs of auto-deploying the latest …
Browse files Browse the repository at this point in the history
…code (kubeflow#320)

* Create a batch job to allow manual runs of auto-deploying the latest cluster.

* * Add a Makefile
* Pass in zone.
* Move to us-east1-b becasue of kubeflow#321

* Fix zones.

* Make zone required.
  • Loading branch information
jlewi authored and k8s-ci-robot committed Mar 1, 2019
1 parent 89bbe15 commit ae94239
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 6 deletions.
46 changes: 46 additions & 0 deletions test-infra/auto-deploy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Requirements:
# https://github.com/mattrobenolt/jinja2-cli
# pip install jinja2-clie
IMG = gcr.io/kubeflow-ci/deploy-worker

# Whether to use cached images with GCB
USE_IMAGE_CACHE ?= true

TAG := $(shell date +v%Y%m%d)-$(shell git describe --tags --always --dirty)-$(shell git diff | shasum -a256 | cut -c -6)
DIR := ${CURDIR}

all: build

# To build without the cache set the environment variable
# export DOCKER_BUILD_OPTS=--no-cache
build:
docker build ${DOCKER_BUILD_OPTS} -t $(IMG):$(TAG) .
@echo Built $(IMG):$(TAG)

# Build but don't attach the latest tag. This allows manual testing/inspection of the image
# first.
push: build
gcloud docker -- push $(IMG):$(TAG)
@echo Pushed $(IMG):$(TAG)
# Add tag starting hitting problems so tag and push
docker tag $(IMG):$(TAG) $(IMG):latest
gcloud docker -- push $(IMG):$(TAG)

build-gcb:
gcloud builds submit --machine-type=n1-highcpu-32 --project=kubeflow-ci \
--tag=$(IMG):$(TAG) \
--timeout=3600
1 change: 1 addition & 0 deletions test-infra/auto-deploy/deploy-cron-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
- --nfs_mnt=/mnt/test-data-volume
- --base_name=kf-vmaster
- --max_num_cluster=5
- --zone=us-east1-b
volumeMounts:
- name: gcp-credentials
mountPath: "/secret/gcp-credentials"
Expand Down
1 change: 1 addition & 0 deletions test-infra/auto-deploy/deploy-cron-v0-4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
- --nfs_mnt=/mnt/test-data-volume
- --base_name=kf-v0-4
- --max_num_cluster=5
- --zone=us-east1-b
volumeMounts:
- name: gcp-credentials
mountPath: "/secret/gcp-credentials"
Expand Down
56 changes: 56 additions & 0 deletions test-infra/auto-deploy/deploy-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: batch/v1
kind: Job
metadata:
generateName: deploy-master-
namespace: kubeflow-test-infra
spec:
template:
spec:
containers:
- name: deploy-worker
image: gcr.io/kubeflow-ci/deploy-worker:v20190228-e625074-dirty-decd62
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secret/gcp-credentials/key.json
command:
- /usr/local/bin/init.sh
- --src_dir=/src
- --repo_owner=kubeflow
- --repo_branches=kubeflow/master,testing/master
- --project=kubeflow-ci
- --worker_cluster=kubeflow-testing
- --job_labels=/etc/pod-info/labels
- --nfs_mnt=/mnt/test-data-volume
- --base_name=kf-vmaster
- --max_num_cluster=5
- --zone=us-east1-b
volumeMounts:
- name: gcp-credentials
mountPath: "/secret/gcp-credentials"
readOnly: true
- name: pod-info
mountPath: "/etc/pod-info"
readOnly: true
- name: github-token
mountPath: "/secret/github-token"
readOnly: true
- name: test-data-volume
mountPath: "/mnt/test-data-volume"
readOnly: false
restartPolicy: Never
volumes:
- name: gcp-credentials
secret:
secretName: gcp-credentials
- name: github-token
secret:
secretName: github-token
- name: test-data-volume
persistentVolumeClaim:
claimName: nfs-external
- name: pod-info
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
5 changes: 3 additions & 2 deletions test-infra/auto-deploy/deployment-workflows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -ex

# Deployment configs.
required_args=(src_dir repo_owner project worker_cluster job_labels nfs_mnt \
base_name)
base_name zone)

parseArgs $*
validateRequiredArgs ${required_args}
Expand Down Expand Up @@ -42,6 +42,7 @@ python -m kubeflow.testing.create_kf_instance \
--deployment_worker_cluster=${worker_cluster} \
--cluster_num=${cluster_num} \
--timestamp=${timestamp} \
--job_name=${job_name}
--job_name=${job_name} \
--zone=${zone}

# TODO(gabrielwen): Push changes to app folders to git.
11 changes: 7 additions & 4 deletions test-infra/auto-deploy/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -ex

# Deployment configs.
required_args=(src_dir repo_owner repo_branches project worker_cluster \
job_labels nfs_mnt base_name max_num_cluster)
job_labels nfs_mnt base_name max_num_cluster zone)

parseArgs $*
validateRequiredArgs ${required_args}
Expand All @@ -27,15 +27,17 @@ python -m checkout_lib.snapshot_kf_deployment \
--repo_owner=${repo_owner} \
--job_labels=${job_labels} \
--nfs_path=${nfs_mnt} \
--max_cluster_num=${max_num_cluster}
--max_cluster_num=${max_num_cluster} \
--zone=${zone}

# Check out fresh copy of KF and deployment workflow.
python -m checkout_lib.repo_clone_snapshot \
--src_dir=${src_dir} \
--project=${project} \
--repo_owner=${repo_owner} \
--job_labels=${job_labels} \
--nfs_path=${nfs_mnt}
--nfs_path=${nfs_mnt} \
--zone=${zone}

export PYTHONPATH="${PYTHONPATH}:${src_dir}/${repo_owner}/testing/py"

Expand All @@ -47,4 +49,5 @@ ${src_dir}/${repo_owner}/testing/test-infra/auto-deploy/deployment-workflows.sh
--worker_cluster=${worker_cluster} \
--job_labels=${job_labels} \
--nfs_mnt=${nfs_mnt} \
--base_name=${base_name}
--base_name=${base_name} \
--zone=${zone}

0 comments on commit ae94239

Please sign in to comment.