This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-deploy-kube.git


The following commit(s) were added to refs/heads/master by this push:
     new fab1c64  include a Helm-based deployment in TravisCI matrix (#187)
fab1c64 is described below

commit fab1c64318bac5cddf98229948b729ad1a0091bd
Author: David Grove <[email protected]>
AuthorDate: Wed May 9 08:44:25 2018 -0400

    include a Helm-based deployment in TravisCI matrix (#187)
---
 .travis.yml                |  12 +--
 tools/travis/build-helm.sh | 189 +++++++++++++++++++++++++++++++++++++++++++++
 tools/travis/build.sh      |   5 ++
 tools/travis/setup.sh      |  59 ++++++++++++++
 4 files changed, 260 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7b38ed4..35de9c9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,11 @@ env:
   - secure: 
d7CuMXbhT83W2x78qiLwgogX1+3aPicd1PlTwwNNDN6QSkImbxareyKThnsqlHIiNj3o5l5DBuiYjy7wrF/xD1g8BQMmTwm99DRx5q3CI3Im3VCi/ZK8SaNjuOy24d7cf5k2tB/87Gk7zmKsMDYm+fpCl+GpgUmIEeIwthiAxuXSDWZ8eQPIptmxj56DeFRNouvXG+dEUtBfWiwN27UPxNKExCixFnegmdtffLbz6hhst7BHr5Ry9acbycre98PCwWZcu9lxFs+SJ1kvnzX2iue4otmDkF1WkJjxaOFPJVs/D3YItg+neLCSxjwBskPed+Fct8bOjcM/uVROJPNIq5icBmaPX2isH0lvtxOeVw/dmioWYXYPN9ygBOe4eO/vtPllN0bcAUo5xl9jXev8ciAozYrYpHVh9Fplfd81rcYTeYzALmRJBdoiWoc3KQGzwGc9sB1ffmy+KWgG9T0zbnS4fALSR4PS
 [...]
   - secure: 
CJtnU94HTDqd4A6uvhFl8IpnmU+wTdlzb8bPBFUl/lI/VKXiRrYpgJdKUro5xEoxFKuqMprLhbyf66niyWLTIeogjUAEu/h/o2dBVeGgSGKoqC0hQgqvnxKFeGlzFJ0XuEs3vbStJGRnQszGsfnnDrscJtR0x9X+1w4aBKI7iPyyuFtVkDD1UsmBbSi+M8FTeq7G7A0reMDaey7uog3CFCpIMl4geshcohQEcKEGbnXQZoLPFpb7cBOE83VXBJ7Y7Dgf/U4keiLovvnuJThGKZm/SVV2KlELmBmtmbx3rMT6Vb5k9ChSdRWapromNnnzmJBIQ5Scc2mwV3A93/SMha1F3IlYpDKs5djfTw8jZfVnuiou7HhTaRjHkmmcwP12/k30gLe2kw0Vezg1TCY4zgtOpcmCxc8RHEy0ceA74rKvRi8LbexTCwX+iAMQFn/pSrh/OqAq/50JbLyczcoO1zXWS38txUQN
 [...]
   matrix:
-    - OW_CONTAINER_FACTORY=docker TRAVIS_KUBE_VERSION=v1.7.4 
TRAVIS_MINIKUBE_VERSION=v0.23.0
-    - OW_CONTAINER_FACTORY=docker TRAVIS_KUBE_VERSION=v1.8.0 
TRAVIS_MINIKUBE_VERSION=v0.25.2
-    - OW_CONTAINER_FACTORY=docker TRAVIS_KUBE_VERSION=v1.9.0 
TRAVIS_MINIKUBE_VERSION=v0.25.2
-    - OW_CONTAINER_FACTORY=kube   TRAVIS_KUBE_VERSION=v1.8.0 
TRAVIS_MINIKUBE_VERSION=v0.25.2
+    - TRAVIS_USE_HELM=false OW_CONTAINER_FACTORY=docker 
TRAVIS_KUBE_VERSION=v1.7.4 TRAVIS_MINIKUBE_VERSION=v0.23.0
+    - TRAVIS_USE_HELM=false OW_CONTAINER_FACTORY=docker 
TRAVIS_KUBE_VERSION=v1.8.0 TRAVIS_MINIKUBE_VERSION=v0.25.2
+    - TRAVIS_USE_HELM=false OW_CONTAINER_FACTORY=docker 
TRAVIS_KUBE_VERSION=v1.9.0 TRAVIS_MINIKUBE_VERSION=v0.25.2
+    - TRAVIS_USE_HELM=true  OW_CONTAINER_FACTORY=docker 
TRAVIS_KUBE_VERSION=v1.9.0 TRAVIS_MINIKUBE_VERSION=v0.25.2
+    - TRAVIS_USE_HELM=false OW_CONTAINER_FACTORY=kube   
TRAVIS_KUBE_VERSION=v1.8.0 TRAVIS_MINIKUBE_VERSION=v0.25.2
 
 services:
   - docker
@@ -26,9 +27,10 @@ before_install:
 
 script:
   - ./tools/travis/scancode.sh
+  - ./tools/travis/build-helm.sh
   - ./tools/travis/build.sh
   - ./tools/travis/collect-logs.sh
-  - ./tools/travis/box-upload.py "logs" 
"deploy-kube-$TRAVIS_BUILD_ID-$TRAVIS_BRANCH.tar.gz"
+  - ./tools/travis/box-upload.py "logs" 
"deploy-kube-$TRAVIS_BUILD_ID-$TRAVIS_BRANCH-$TRAVIS_JOB_NUMBER.tar.gz"
 
 deploy:
 - provider: script
diff --git a/tools/travis/build-helm.sh b/tools/travis/build-helm.sh
new file mode 100755
index 0000000..495f7fc
--- /dev/null
+++ b/tools/travis/build-helm.sh
@@ -0,0 +1,189 @@
+#!/bin/bash
+
+#################
+# Helper functions for verifying pod creation
+#################
+
+deploymentHealthCheck () {
+  if [ -z "$1" ]; then
+    echo "Error, component health check called without a component parameter"
+    exit 1
+  fi
+
+  PASSED=false
+  TIMEOUT=0
+  until $PASSED || [ $TIMEOUT -eq $TIMEOUT_STEP_LIMIT ]; do
+    KUBE_DEPLOY_STATUS=$(kubectl -n openwhisk get pods -l name="$1" -o wide | 
grep "$1" | awk '{print $3}')
+    if [ "$KUBE_DEPLOY_STATUS" == "Running" ]; then
+      PASSED=true
+      break
+    fi
+
+    kubectl get pods --all-namespaces -o wide --show-all
+
+    let TIMEOUT=TIMEOUT+1
+    sleep 10
+  done
+
+  if [ "$PASSED" = false ]; then
+    echo "Failed to finish deploying $1"
+
+    kubectl -n openwhisk logs $(kubectl -n openwhisk get pods -l name="$1" -o 
wide | grep "$1" | awk '{print $1}')
+    exit 1
+  fi
+
+  echo "$1 is up and running"
+}
+
+statefulsetHealthCheck () {
+  if [ -z "$1" ]; then
+    echo "Error, StatefulSet health check called without a parameter"
+    exit 1
+  fi
+
+  PASSED=false
+  TIMEOUT=0
+  until $PASSED || [ $TIMEOUT -eq $TIMEOUT_STEP_LIMIT ]; do
+    KUBE_DEPLOY_STATUS=$(kubectl -n openwhisk get pods -l name="$1" -o wide | 
grep "$1"-0 | awk '{print $3}')
+    if [ "$KUBE_DEPLOY_STATUS" == "Running" ]; then
+      PASSED=true
+      break
+    fi
+
+    kubectl get pods --all-namespaces -o wide --show-all
+
+    let TIMEOUT=TIMEOUT+1
+    sleep 10
+  done
+
+  if [ "$PASSED" = false ]; then
+    echo "Failed to finish deploying $1"
+
+    kubectl -n openwhisk logs $(kubectl -n openwhisk get pods -o wide | grep 
"$1"-0 | awk '{print $1}')
+    exit 1
+  fi
+
+  echo "$1-0 is up and running"
+
+}
+
+jobHealthCheck () {
+  if [ -z "$1" ]; then
+    echo "Error, job health check called without a component parameter"
+    exit 1
+  fi
+
+  PASSED=false
+  TIMEOUT=0
+  until $PASSED || [ $TIMEOUT -eq $TIMEOUT_STEP_LIMIT ]; do
+    KUBE_SUCCESSFUL_JOB=$(kubectl -n openwhisk get jobs -o wide | grep "$1" | 
awk '{print $3}')
+    if [ "$KUBE_SUCCESSFUL_JOB" == "1" ]; then
+      PASSED=true
+      break
+    fi
+
+    kubectl get jobs --all-namespaces -o wide --show-all
+
+    let TIMEOUT=TIMEOUT+1
+    sleep 10
+  done
+
+  if [ "$PASSED" = false ]; then
+    echo "Failed to finish running $1"
+
+    kubectl -n openwhisk logs jobs/$1
+    exit 1
+  fi
+
+  echo "$1 completed"
+}
+
+
+#################
+# Main body of script -- deploy OpenWhisk
+#################
+
+set -x
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+ROOTDIR="$SCRIPTDIR/../../"
+
+# If TRAVIS and !TRAVIS_USE_HELM, just exit (don't test HELM deploy)
+if [[ "$TRAVIS" = "true" ]] && [[ "$TRAVIS_USE_HELM" = "false" ]]; then
+    exit 0
+fi
+
+# Default to docker container factory if not specified
+OW_CONTAINER_FACTORY=${OW_CONTAINER_FACTORY:="docker"}
+
+# Default timeout limit to 60 steps
+TIMEOUT_STEP_LIMIT=${TIMEOUT_STEP_LIMIT:=60}
+
+# Label invoker nodes (needed for DockerContainerFactory-based invoker 
deployment)
+echo "Labeling invoker node"
+kubectl label nodes --all openwhisk-role=invoker
+kubectl describe nodes
+
+# Create namespace
+echo "Create openwhisk namespace"
+kubectl create namespace openwhisk
+
+# configure Ingress and wsk CLI
+#
+# FIXME: Helm deploy hardwires ports to specific values -- need to make this 
less fragile!
+WSK_PORT=31001
+APIGW_PORT=31004
+WSK_HOST=$(kubectl describe nodes | grep Hostname: | awk '{print $2}')
+if [ "$WSK_HOST" = "minikube" ]; then
+    WSK_HOST=$(minikube ip)
+fi
+wsk property set --auth `cat $ROOTDIR/kubernetes/cluster-setup/auth.guest` 
--apihost $WSK_HOST:$WSK_PORT
+
+# Deploy OpenWhisk using Helm
+cd $ROOTDIR/helm
+
+cat > mycluster.yaml <<EOF
+whisk:
+  ingress:
+    api_host: $WSK_HOST:$WSK_PORT
+    apigw_url: $WSK_HOST:$APIGW_PORT
+EOF
+
+cat mycluster.yaml
+
+helm install . --namespace=openwhisk --name=ow4travis -f mycluster.yaml
+
+# Wait for controller and invoker to be up
+statefulsetHealthCheck "controller"
+deploymentHealthCheck "invoker"
+
+#################
+# Sniff test: create and invoke a simple Hello world action
+#################
+
+# create wsk action
+cat > hello.js << EOL
+function main() {
+  return {payload: 'Hello world'};
+}
+EOL
+
+wsk -i action create hello hello.js
+
+sleep 5
+
+# run the new hello world action
+RESULT=$(wsk -i action invoke --blocking hello | grep "\"status\": 
\"success\"")
+
+if [ -z "$RESULT" ]; then
+  echo "FAILED! Could not invoked custom action"
+
+  echo " ----------------------------- controller logs 
---------------------------"
+  kubectl -n openwhisk logs controller-0
+
+  echo " ----------------------------- invoker logs 
---------------------------"
+  kubectl -n openwhisk logs -l name=invoker
+  exit 1
+fi
+
+echo "PASSED! Deployed openwhisk and invoked Hello action"
diff --git a/tools/travis/build.sh b/tools/travis/build.sh
index d023c38..edec5bf 100755
--- a/tools/travis/build.sh
+++ b/tools/travis/build.sh
@@ -135,6 +135,11 @@ set -x
 SCRIPTDIR=$(cd $(dirname "$0") && pwd)
 ROOTDIR="$SCRIPTDIR/../../"
 
+# If TRAVIS and TRAVIS_USE_HELM, just exit (don't test non-HELM deploy)
+if [[ "$TRAVIS" = "true" ]] && [[ "$TRAVIS_USE_HELM" = "true" ]]; then
+    exit 0
+fi
+
 # Default to docker container factory if not specified
 OW_CONTAINER_FACTORY=${OW_CONTAINER_FACTORY:="docker"}
 
diff --git a/tools/travis/setup.sh b/tools/travis/setup.sh
index d952477..cd40d29 100755
--- a/tools/travis/setup.sh
+++ b/tools/travis/setup.sh
@@ -3,6 +3,33 @@
 
 set -x
 
+#check_or_build_nsenter derived from 
https://github.com/bitnami/kubernetes-travis/blob/master/scripts/cluster-up-minikube.sh
 (Apache 2.0 License)
+check_or_build_nsenter() {
+    which nsenter >/dev/null && return 0
+    echo "INFO: Building 'nsenter' ..."
+cat <<-EOF | docker run -i --rm -v "$(pwd):/build" ubuntu:14.04 >& 
nsenter.build.log
+        apt-get update
+        apt-get install -qy git bison build-essential autopoint libtool 
automake autoconf gettext pkg-config
+        git clone --depth 1 
git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git /tmp/util-linux
+        cd /tmp/util-linux
+        ./autogen.sh
+        ./configure --without-python --disable-all-programs --enable-nsenter
+        make nsenter
+        cp -pfv nsenter /build
+EOF
+    if [ ! -f ./nsenter ]; then
+        echo "ERROR: nsenter build failed, log:"
+        cat nsenter.build.log
+        return 1
+    fi
+    echo "INFO: nsenter build OK, installing ..."
+    sudo install -v nsenter /usr/local/bin
+}
+
+# helm on minikube's vm-driver=none requires nsenter
+check_or_build_nsenter
+
+
 # download and install the wsk cli
 wget -q 
https://github.com/apache/incubator-openwhisk-cli/releases/download/latest/OpenWhisk_CLI-latest-linux-amd64.tgz
 tar xzf OpenWhisk_CLI-latest-linux-amd64.tgz
@@ -46,3 +73,35 @@ fi
 
 echo "minikube is deployed and reachable"
 /usr/local/bin/kubectl describe nodes
+
+minikube update-context
+
+# Download and install helm
+curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > 
get_helm.sh
+chmod +x get_helm.sh
+./get_helm.sh
+
+# Install tiller
+/usr/local/bin/helm init --service-account default
+
+# Wait for tiller to be ready
+TIMEOUT=0
+TIMEOUT_COUNT=20
+until [ $TIMEOUT -eq $TIMEOUT_COUNT ]; do
+  TILLER_STATUS=$(/usr/local/bin/kubectl -n kube-system get pods -o wide | 
grep tiller-deploy | awk '{print $3}')
+  if [ "$TILLER_STATUS" == "Running" ]; then
+    break
+  fi
+  echo "Waiting for tiller to be ready"
+  /usr/local/bin/kubectl -n kube-system get pods -o wide
+  let TIMEOUT=TIMEOUT+1
+  sleep 5
+done
+
+if [ $TIMEOUT -eq $TIMEOUT_COUNT ]; then
+  echo "Failed to install tiller"
+  exit 1
+fi
+
+# Create privileged RBAC for tiller
+/usr/local/bin/kubectl create clusterrolebinding tiller-cluster-admin 
--clusterrole=cluster-admin --serviceaccount=kube-system:default

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to