diff --git a/.travis.yml b/.travis.yml index 64a6cce693..37671c4350 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,10 +37,27 @@ jobs: - make e2e-test-kind after_failure: # Echo logs and upload - - test -f helm-tiller.log && "******<>******" && cat helm-tiller.log + - test -f helm-tiller.log && "echo ******<>******" && cat helm-tiller.log - test -f volcano-admission.log && echo "******<>******" && cat volcano-admission.log - test -f volcano-controller.log && echo "******<>******" && cat volcano-controller.log - test -f volcano-scheduler.log && echo "******<>******" && cat volcano-scheduler.log + - stage: Publish release + before_deploy: + - export TRAVIS_TAG=$(git describe --tags) + script: + - echo "publish release to github & dockerhub" + deploy: + - provider: script + script: make TAG=${TRAVIS_TAG} RELEASE_VER=${TRAVIS_TAG} release + on: + tags: true + - provider: releases + api_key: $GITHUB_TOKEN + file_glob: true + file: _output/release/volcano-${TRAVIS_TAG}-${OSTYPE}.tar.gz + skip_cleanup: true + on: + tags: true notifications: webhooks: https://www.travisbuddy.com/ on_success: never diff --git a/Makefile b/Makefile index 96de90b70b..f998d1fcc5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ BIN_DIR=_output/bin +RELEASE_DIR=_output/release REL_OSARCH=linux/amd64 REPO_PATH=volcano.sh/volcano IMAGE_PREFIX=volcanosh/vc @@ -17,6 +18,7 @@ all: vc-scheduler vc-controllers vc-admission vcctl init: mkdir -p ${BIN_DIR} + mkdir -p ${RELEASE_DIR} vc-scheduler: init go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/vc-scheduler ./cmd/scheduler @@ -30,7 +32,7 @@ vc-admission: init vcctl: init go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/vcctl ./cmd/cli -image_bins: +image_bins: init go get github.com/mitchellh/gox CGO_ENABLED=0 gox -osarch=${REL_OSARCH} -ldflags ${LD_FLAGS} -output ${BIN_DIR}/${REL_OSARCH}/vcctl ./cmd/cli for name in controllers scheduler admission; do\ @@ -56,6 +58,13 @@ unit-test: e2e-test-kind: ./hack/run-e2e-kind.sh +generate-yaml: init + ./hack/generate-yaml.sh + + +release: images generate-yaml + ./hack/publish.sh + clean: rm -rf _output/ rm -f *.log diff --git a/hack/generate-yaml.sh b/hack/generate-yaml.sh new file mode 100755 index 0000000000..770506f8ed --- /dev/null +++ b/hack/generate-yaml.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# Copyright 2019 The Volcano 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. + +set -o errexit +set -o nounset +set -o pipefail + +VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.. +export HELM_BIN_DIR=${VK_ROOT}/${BIN_DIR} +export RELEASE_FOLDER=${VK_ROOT}/${RELEASE_DIR} + +export HELM_VER=${HELM_VER:-v2.13.0} +export VOLCANO_IMAGE_TAG=${TAG:-"latest"} +export YAML_FILENAME=volcano-${VOLCANO_IMAGE_TAG}.yaml + +LOCAL_OS=${OSTYPE} +case $LOCAL_OS in + "linux"*) + LOCAL_OS='linux' + ;; + "darwin"*) + LOCAL_OS='darwin' + ;; + *) + echo "This system's OS ${LOCAL_OS} isn't recognized/supported" + exit 1 + ;; +esac + +# Step1. install helm binary +if [[ ! -f "${HELM_BIN_DIR}/version.helm.${HELM_VER}" ]] ; then + TD=$(mktemp -d) + cd "${TD}" && \ + curl -Lo "${TD}/helm.tgz" "https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VER}-${LOCAL_OS}-amd64.tar.gz" && \ + tar xfz helm.tgz && \ + mv ${LOCAL_OS}-amd64/helm "${HELM_BIN_DIR}/helm-${HELM_VER}" && \ + cp "${HELM_BIN_DIR}/helm-${HELM_VER}" "${HELM_BIN_DIR}/helm" && \ + chmod +x ${HELM_BIN_DIR}/helm + rm -rf "${TD}" && \ + touch "${HELM_BIN_DIR}/version.helm.${HELM_VER}" +fi + +# Step2. generate yaml in folder +if [[ ! -d ${RELEASE_FOLDER} ]];then + mkdir ${RELEASE_FOLDER} +fi + +DEPLOYMENT_FILE=${RELEASE_FOLDER}/${YAML_FILENAME} +echo "Generating volcano yaml file into ${DEPLOYMENT_FILE}}" + +if [[ -f ${DEPLOYMENT_FILE} ]];then + rm ${DEPLOYMENT_FILE} +fi +cat ${VK_ROOT}/installer/namespace.yaml > ${DEPLOYMENT_FILE} +${HELM_BIN_DIR}/helm template ${VK_ROOT}/installer/helm/chart/volcano --namespace volcano-system \ + --name volcano --set basic.image_tag_version=${VOLCANO_IMAGE_TAG} \ + --set basic.scheduler_config_file=kube-batch-ci.conf \ + -x templates/admission.yaml \ + -x templates/batch_v1alpha1_job.yaml \ + -x templates/bus_v1alpha1_command.yaml \ + -x templates/controllers.yaml \ + -x templates/scheduler.yaml \ + -x templates/scheduling_v1alpha1_podgroup.yaml \ + -x templates/scheduling_v1alpha1_queue.yaml \ + -x templates/scheduling_v1alpha2_podgroup.yaml \ + -x templates/scheduling_v1alpha2_queue.yaml \ + --notes >> ${DEPLOYMENT_FILE} diff --git a/hack/publish.sh b/hack/publish.sh new file mode 100755 index 0000000000..3a1eb8b04d --- /dev/null +++ b/hack/publish.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# Copyright 2019 The Volcano 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. + +set -o errexit +set -o nounset +set -o pipefail + + + +# The process of preparing volcano release. +# 1. cp binaries into release folder +# 2. cp README document into release folder +# 3. cp default queue into release folder +# 4. cp helm charts template into release folder and update default image tag +# 5. cp license file into release folder +# 6. upload docker images to volcano.sh +# 7. generate zip file + +VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.. +BINARY_FOLDER=${VK_ROOT}/${BIN_DIR}/${REL_OSARCH} +RELEASE_FOLDER=${VK_ROOT}/${RELEASE_DIR} +RELEASE_BINARY=${RELEASE_FOLDER}/bin +QUEUE_FILE=${VK_ROOT}/installer/helm/chart/volcano/templates/default-queue.yaml +README_FILE=${VK_ROOT}/installer/README.md +HELM_FOLDER=${VK_ROOT}/installer/helm +VOLCANO_IMAGE_TAG=${TAG:-"latest"} +DOCKER_PASSWORD=${DOCKER_PASSWORD:-""} +DOCKER_USERNAME=${DOCKER_USERNAME:-""} +LICENSE_FILE=${VK_ROOT}/LICENSE + +if [[ ! -d ${RELEASE_BINARY} ]];then + mkdir ${RELEASE_BINARY} +fi + +cp -r ${BINARY_FOLDER} ${RELEASE_BINARY} + +cp ${README_FILE} ${RELEASE_FOLDER} + +cp ${QUEUE_FILE} ${RELEASE_FOLDER} + +cp -r ${HELM_FOLDER} ${RELEASE_FOLDER} + +if [[ -f ${LICENSE_FILE} ]];then + cp ${LICENSE_FILE} ${RELEASE_FOLDER} +fi + +# overwrite the tag name into values yaml +sed -i "s/latest/${VOLCANO_IMAGE_TAG}/g" ${RELEASE_FOLDER}/helm/chart/volcano/values.yaml + +if [[ "${DOCKER_USERNAME}xxx" == "xxx" ]];then + if [[ "${DOCKER_PASSWORD}xxx" == "xxx" ]];then + echo "docker username or password not found, quit uploading images" + exit 0 + fi +fi + +echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin +echo "pushing ${IMAGE_PREFIX}-controllers:${VOLCANO_IMAGE_TAG}" +docker push ${IMAGE_PREFIX}-controllers:${VOLCANO_IMAGE_TAG} +docker push ${IMAGE_PREFIX}-scheduler:${VOLCANO_IMAGE_TAG} +docker push ${IMAGE_PREFIX}-admission:${VOLCANO_IMAGE_TAG} + +echo "Generate release tar files" +cd ${RELEASE_FOLDER}/ +tar -zcvf volcano-${VOLCANO_IMAGE_TAG}-${OSTYPE}.tar.gz * diff --git a/installer/README.md b/installer/README.md new file mode 100644 index 0000000000..faf9584a6e --- /dev/null +++ b/installer/README.md @@ -0,0 +1,102 @@ +## Volcano + +Volcano is a batch system built on Kubernetes. It provides a suite of mechanisms currently missing from +Kubernetes that are commonly required by many classes of batch & elastic workload including: + +1. machine learning/deep learning, +2. bioinformatics/genomics, and +3. other "big data" applications. + +## Prerequisites + +- Kubernetes 1.12+ with CRD support + +## Installing volcano via yaml file + +All-in-one yaml has been generated for quick deployment. Try command: +```$xslt +kubectl apply -f volcano-v0.0.x.yaml +``` +Check the status in namespace `volcano-system` +```$xslt +$kubectl get all -n volcano-system +NAME READY STATUS RESTARTS AGE +pod/volcano-admission-56f5465597-2pbfx 1/1 Running 0 36s +pod/volcano-admission-init-pjgf2 0/1 Completed 0 36s +pod/volcano-controllers-687948d9c8-zdtvw 1/1 Running 0 36s +pod/volcano-scheduler-94998fc64-86hzn 1/1 Running 0 36s + + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +service/volcano-admission-service ClusterIP 10.103.235.185 443/TCP 36s + + +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/volcano-admission 1/1 1 1 36s +deployment.apps/volcano-controllers 1/1 1 1 36s +deployment.apps/volcano-scheduler 1/1 1 1 36s + +NAME DESIRED CURRENT READY AGE +replicaset.apps/volcano-admission-56f5465597 1 1 1 36s +replicaset.apps/volcano-controllers-687948d9c8 1 1 1 36s +replicaset.apps/volcano-scheduler-94998fc64 1 1 1 36s +``` +Volcano scheduler utilize `queues.scheduling.incubator.k8s.io` to share resource, therefore default queue is required before usage. +```$xslt +kubectl apply -f default-queue.yaml +``` + +## Installing volcano via helm charts + +To install the volcano with chart: + +```bash +helm install helm/chart/volcano --namespace --name + +e.g : +helm install helm/chart/volcano --namespace volcano-trial --name volcano-trial +``` + +This command deploys volcano in kubernetes cluster with default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + + +## Uninstalling the Chart + +```bash +$ helm delete volcano-release --purge +``` + +## Configuration + +The following are the list configurable parameters of Volcano Chart and their default values. + +| Parameter|Description|Default Value| +|----------------|-----------------|----------------------| +|`basic.image_tag_version`| Docker image version Tag | `latest`| +|`basic.controller_image_name`|Controller Docker Image Name|`volcanosh/vc-controllers`| +|`basic.scheduler_image_name`|Scheduler Docker Image Name|`volcanosh/vc-scheduler`| +|`basic.admission_image_name`|Admission Controller Image Name|`volcanosh/vc-admission`| +|`basic.admission_secret_name`|Volcano Admission Secret Name|`volcano-admission-secret`| +|`basic.scheduler_config_file`|Configuration File name for Scheduler|`kube-batch.conf`| +|`basic.image_pull_secret`|Image Pull Secret|`""`| +|`basic.image_pull_policy`|Image Pull Policy|`IfNotPresent`| +|`basic.admission_app_name`|Admission Controller App Name|`volcano-admission`| +|`basic.controller_app_name`|Controller App Name|`volcano-controller`| +|`basic.scheduler_app_name`|Scheduler App Name|`volcano-scheduler`| + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name volcano-release --set basic.image_pull_policy=Always volcano/volcano +``` + +The above command set image pull policy to `Always`, so docker image will be pulled each time. + + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name volcano-release -f values.yaml volcano/volcano +``` + +> **Tip**: You can use the default [values.yaml](chart/volcano/values.yaml) diff --git a/installer/helm/chart/volcano/templates/NOTES.txt b/installer/helm/chart/volcano/templates/NOTES.txt new file mode 100644 index 0000000000..4e4516d55c --- /dev/null +++ b/installer/helm/chart/volcano/templates/NOTES.txt @@ -0,0 +1,6 @@ +Thank you for installing {{ .Chart.Name }}. + +Your release is named {{ .Release.Name }}. + +For more information on volcano, visit: +https://volcano.sh/ diff --git a/installer/namespace.yaml b/installer/namespace.yaml new file mode 100644 index 0000000000..a6e22db214 --- /dev/null +++ b/installer/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: volcano-system