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

Support Travis CI #28

Merged
merged 8 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
dist: xenial
language: go

go:
- '1.11.x'
sudo: required

env:
- HOME=/home/travis

services:
- docker

go:
- "1.11"

go_import_path: volcano.sh/volcano

install:
- go get -u golang.org/x/lint/golint

script:
- make
- make verify
- make e2e-test

jobs:
include:
- stage: Golint & Gofmt
before_script:
- go get -u golang.org/x/lint/golint
script:
- make
- make verify
- stage: E2E Tests
before_script:
# Download kubectl
- sudo apt-get update && sudo apt-get install -y apt-transport-https
- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
- echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
- sudo apt-get update
- sudo apt-get install -y kubectl
# Download and build kind
- go get sigs.k8s.io/kind
TommyLike marked this conversation as resolved.
Show resolved Hide resolved
script:
- make cli
- make docker
- make e2e-test-kind
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BIN_DIR=_output/bin
IMAGE=volcano
TAG = 1.0
export IMAGE=volcano
export TAG = 1.0

all: controllers scheduler cli admission

Expand Down
2 changes: 1 addition & 1 deletion hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ volcano.sh/volcano/pkg/scheduler/plugins/predicates
volcano.sh/volcano/pkg/scheduler/plugins/priority
volcano.sh/volcano/pkg/scheduler/plugins/proportion
volcano.sh/volcano/pkg/scheduler/util
volcano.sh/volcano/test/e2e
volcano.sh/volcano/test/e2e
18 changes: 1 addition & 17 deletions hack/e2e-kind-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,7 @@ apiVersion: kind.sigs.k8s.io/v1alpha2
nodes:
# the control plane node config
- role: control-plane
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
networking:
serviceSubnet: 10.0.0.0/16
# patch it further using a JSON 6902 patch
kubeadmConfigPatchesJson6902:
- group: kubeadm.k8s.io
version: v1beta1
kind: ClusterConfiguration
patch: |
- op: add
path: /apiServer/certSANs/-
value: my-hostname
# the three workers
- role: worker
# replicas specifes the number of nodes to create with this configuration
# replicas specifies the number of nodes to create with this configuration
replicas: 3
TommyLike marked this conversation as resolved.
Show resolved Hide resolved
74 changes: 27 additions & 47 deletions hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

export VK_ROOT=$(dirname "${BASH_SOURCE}")/..
export VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/..
export VK_BIN=${VK_ROOT}/_output/bin
export LOG_LEVEL=3
export SHOW_VOLCANO_LOGS=${SHOW_VOLCANO_LOGS:-1}
Expand All @@ -9,9 +9,7 @@ if [ "${CLUSTER_NAME}xxx" != "xxx" ];then
export CLUSTER_CONTEXT="--name ${CLUSTER_NAME}"
fi
TommyLike marked this conversation as resolved.
Show resolved Hide resolved

export KIND_OPT=${KIND_OPT:="--image kindest/node:v1.13.2 --config ${VK_ROOT}/hack/e2e-kind-config.yaml"}

export KIND_IMAGE=$(echo ${KIND_OPT} |grep -E -o "image \w+\/[^ ]*" | sed "s/image //")
export KIND_OPT=${KIND_OPT:=" --config ${VK_ROOT}/hack/e2e-kind-config.yaml"}

# check if kind installed
function check-prerequisites {
Expand All @@ -33,48 +31,39 @@ function check-prerequisites {
fi
}

# check if the images that kind use exists.
function check-kind-image {
docker images | awk '{print $1":"$2}' | grep -q "${KIND_IMAGE}"
if [ $? -ne 0 ]; then
echo "image: ${KIND_IMAGE} not found."
exit 1
fi
}

# spin up cluster with kind command
function kind-up-cluster {
check-prerequisites
check-kind-image
echo "Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}]"
kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}
}

function install-volcano {
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_podgroup.yaml
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_queue.yaml
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/batch_v1alpha1_job.yaml
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/bus_v1alpha1_command.yaml

# TODO: make vk-controllers and vk-scheduler run in container / in k8s
# start controller
nohup ${VK_BIN}/vk-controllers --kubeconfig ${KUBECONFIG} --logtostderr --v ${LOG_LEVEL} > controller.log 2>&1 &
echo $! > vk-controllers.pid

# start scheduler
nohup ${VK_BIN}/vk-scheduler --kubeconfig ${KUBECONFIG} --scheduler-conf=example/kube-batch-conf.yaml --logtostderr --v ${LOG_LEVEL} > scheduler.log 2>&1 &
echo $! > vk-scheduler.pid
echo "Preparing helm tiller service account"
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller

echo "Install helm via script and waiting tiller becomes ready"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
#TODO: There are some issue with helm's latest version, remove '--version' when it get fixed.
chmod 700 get_helm.sh && ./get_helm.sh --version v2.13.0
helm init --service-account tiller --kubeconfig ${KUBECONFIG} --wait

echo "Loading docker images into kind cluster"
kind load docker-image ${IMAGE}-controllers:${TAG}
kind load docker-image ${IMAGE}-scheduler:${TAG}
kind load docker-image ${IMAGE}-admission:${TAG}

echo "Install volcano plugin into cluster...."
helm plugin install --kubeconfig ${KUBECONFIG} installer/chart/volcano/plugins/gen-admission-secret
helm gen-admission-secret --service integration-admission-service --namespace kube-system

echo "Install volcano chart"
helm install installer/chart/volcano --namespace kube-system --name integration --kubeconfig ${KUBECONFIG}
}

function uninstall-volcano {
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_podgroup.yaml
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_queue.yaml
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/batch_v1alpha1_job.yaml
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/bus_v1alpha1_command.yaml

kill -9 $(cat vk-controllers.pid)
kill -9 $(cat vk-scheduler.pid)
rm vk-controllers.pid vk-scheduler.pid
helm delete integration --purge --kubeconfig ${KUBECONFIG}
}

# clean up
Expand All @@ -85,17 +74,8 @@ function cleanup {
kind delete cluster ${CLUSTER_CONTEXT}

if [ ${SHOW_VOLCANO_LOGS} -eq 1 ]; then
echo "===================================================================================="
echo "=============================>>>>> Scheduler Logs <<<<<============================="
echo "===================================================================================="

cat scheduler.log

echo "===================================================================================="
echo "=============================>>>>> Controller Logs <<<<<============================"
echo "===================================================================================="

cat controller.log
#TODO: Add volcano logs support in future.
echo "Volcano logs are currently not supported."
fi
}

Expand All @@ -122,7 +102,7 @@ trap cleanup EXIT

kind-up-cluster

KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})"
export KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})"

install-volcano

Expand Down
2 changes: 1 addition & 1 deletion hack/verify-golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ for p in "${all_packages[@]}"; do
# and not just the ones for the current platform.
# Packages with a corresponding foo_test package will make golint fail
# with a useless error. Just ignore that, see golang/lint#68.
failedLint=$(golint "$p"/*.go 2>/dev/null)
failedLint=$(golint "$p" 2>/dev/null)
array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$?
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
errors+=( "${failedLint}" )
Expand Down