Skip to content

Commit

Permalink
be kind, rewind (#3540)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeefy authored and k8s-ci-robot committed Feb 5, 2019
1 parent 1bbe498 commit 43c9568
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 42 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ jobs:
after_success:
- rm -rf $TRAVIS_BUILD_DIR/.tmp
- bash <(curl -s https://codecov.io/bash)
- addons:
sauce_connect: true
script:
- npm run cluster
- npm run test:e2e
env:
- KUBE_DASHBOARD_KUBECONFIG=$HOME/.kube/config
- script: npm run cluster:start && npm run test:e2e
- stage: deploy
script:
- docker login -u $DOCKER_USER -p $DOCKER_PASS
Expand Down
5 changes: 2 additions & 3 deletions aio/scripts/conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ ARCH=$(uname | awk '{print tolower($0)}')
# Local cluster configuration (check start-cluster.sh script for more details).
HEAPSTER_VERSION="v1.5.4"
HEAPSTER_PORT=8082
MINIKUBE_VERSION=v0.32.0
MINIKUBE_K8S_VERSION=v1.12.4
MINIKUBE_BIN=${CACHE_DIR}/minikube-${MINIKUBE_VERSION}
KIND_VERSION="0.1.0"
KIND_BIN=${CACHE_DIR}/kind-${KIND_VERSION}

# Setup logger.
ERROR_STYLE=`tput setaf 1`
Expand Down
47 changes: 16 additions & 31 deletions aio/scripts/start-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,24 @@ function ensure-cache {
mkdir -p ${CACHE_DIR}
}

function download-minikube {
say "\nDownloading minikube ${MINIKUBE_VERSION} if it is not cached"
wget -nc -O ${MINIKUBE_BIN} https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-${ARCH}-amd64
chmod +x ${MINIKUBE_BIN}
${MINIKUBE_BIN} version
function download-kind {
KIND_URL="https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-${ARCH}-amd64"
say "\nDownloading kind ${KIND_URL} if it is not cached"
wget -nc -O ${KIND_BIN} ${KIND_URL}
chmod +x ${KIND_BIN}
${KIND_BIN} version
}

function ensure-kubeconfig {
say "\nMaking sure that kubeconfig file exists and will be used by Dashboard"
mkdir -p ${HOME}/.kube
touch ${HOME}/.kube/config
}

function configure-minikube {
say "\nConfiguring minikube"
export MINIKUBE_HOME=${HOME}
sudo -E ${MINIKUBE_BIN} config set WantUpdateNotification false
sudo -E ${MINIKUBE_BIN} config set WantReportErrorPrompt false
sudo -E ${MINIKUBE_BIN} config set WantKubectlDownloadMsg false
}

function start-ci-minikube {
say "\nStarting continous integration cluster"
export CHANGE_MINIKUBE_NONE_USER=true
sudo -E ${MINIKUBE_BIN} start --vm-driver=none --kubernetes-version=${MINIKUBE_K8S_VERSION}
# Let's back up the kubeconfig so we don't totally blow it away
# I learned from personal experience. It made me sad. :(
mv ${HOME}/.kube/config ${HOME}/.kube/config-unkind

cat $(${KIND_BIN} get kubeconfig-path --name="k8s-cluster-ci") > $HOME/.kube/config
}

function start-ci-heapster {
Expand All @@ -67,24 +60,16 @@ function start-ci-heapster {
say "\nHeapster is up and running"
}

function start-local-minikube {
say "\nStarting local cluster"
sudo -E ${MINIKUBE_BIN} start --kubernetes-version=${MINIKUBE_K8S_VERSION}
}

function start-minikube {
function start-kind {
${KIND_BIN} create cluster --name="k8s-cluster-ci"
ensure-kubeconfig
if [ "${CI}" = true ] ; then
start-ci-minikube
start-ci-heapster
else
start-local-minikube
fi
say "\nKubernetes cluster is ready to use"
}

# Execute script.
ensure-cache
download-minikube
ensure-kubeconfig
configure-minikube
start-minikube
download-kind
start-kind
7 changes: 7 additions & 0 deletions aio/scripts/stop-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
. "./aio/scripts/conf.sh"

${KIND_BIN} delete cluster --name="k8s-cluster-ci"

# Restore the original kubeconfig and all's right
# with the world.
mv ${HOME}/.kube/config-unkind ${HOME}/.kube/config
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"test:backend:coverage": "./aio/scripts/coverage-backend.sh",
"test:coverage": "npm run test:frontend:coverage && npm run test:backend:coverage",
"test:e2e": "ng e2e",
"cluster": "./aio/scripts/start-cluster.sh",
"cluster:start": "./aio/scripts/start-cluster.sh",
"cluster:stop": "./aio/scripts/stop-cluster.sh",
"check": "concurrently \"npm run check:backend\" \"npm run check:frontend\" \"npm run check:license\"",
"check:backend": "./aio/scripts/lint-backend.sh",
"check:frontend": "concurrently \"npm run check:frontend:ts\" \"npm run check:frontend:scss\" \"npm run check:frontend:html\"",
Expand Down

0 comments on commit 43c9568

Please sign in to comment.