From 98290cea10a45acbe6eace570ec5b741077b125f Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Sun, 11 Feb 2018 23:08:13 +0530 Subject: [PATCH 1/2] setup ci using minikube for openebs provisioner Notes: Installs minikube in the travis Install openebs via helm chart Install openebs-provisioner ci image Signed-off-by: kmova --- .travis.yml | 23 +++++++++++++++++++++++ openebs-build.sh | 4 ++-- openebs-ci.sh | 27 +++++++++++++++++++++++++++ openebs/ci/helm_install_openebs.sh | 18 ++++++++++++++++++ openebs/ci/travis-ci.sh | 18 ++++++++++++++++++ openebs/ci/ubuntu-compile-nsenter.sh | 23 +++++++++++++++++++++++ 6 files changed, 111 insertions(+), 2 deletions(-) create mode 100755 openebs-ci.sh create mode 100755 openebs/ci/helm_install_openebs.sh create mode 100755 openebs/ci/travis-ci.sh create mode 100755 openebs/ci/ubuntu-compile-nsenter.sh diff --git a/.travis.yml b/.travis.yml index c0c1dff4591..57423760f00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,35 @@ language: go +env: +- CHANGE_MINIKUBE_NONE_USER=true go: - 1.8.3 services: docker install: true +before_script: + # Download kubectl, which is a requirement for using minikube. + - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.7.5/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + # Download minikube. + - curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ + - sudo minikube start --vm-driver=none --kubernetes-version=v1.7.5 + # Fix the kubectl context, as it's often stale. + - minikube update-context + # Wait for Kubernetes to be up and ready. + - JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done + # Download and initialize helm. + - ./openebs/ci/ubuntu-compile-nsenter.sh && sudo cp .tmp/util-linux-2.30.2/nsenter /usr/bin + - curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh + - chmod 700 get_helm.sh + - ./get_helm.sh + - helm init + script: - ./openebs-build.sh + # Verify that minkube is setup + - kubectl cluster-info + - kubectl get deployment + - ./openebs-ci.sh after_success: - ./openebs-deploy.sh diff --git a/openebs-build.sh b/openebs-build.sh index d3fa16a4006..035d72d4b44 100755 --- a/openebs-build.sh +++ b/openebs-build.sh @@ -14,11 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -SRC_REPO="$GOPATH/src/github.com/openebs" +SRC_REPO=`pwd` DST_REPO="$GOPATH/src/github.com/kubernetes-incubator" mkdir -p $DST_REPO -cp -R $SRC_REPO/external-storage $DST_REPO +cp -R $SRC_REPO/../external-storage $DST_REPO cd $DST_REPO/external-storage make openebs diff --git a/openebs-ci.sh b/openebs-ci.sh new file mode 100755 index 00000000000..d797c2a750f --- /dev/null +++ b/openebs-ci.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright 2017 The OpenEBS 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. + +DST_REPO="$GOPATH/src/github.com/kubernetes-incubator" +export DST_REPO + +export DIMAGE="openebs/openebs-k8s-provisioner" +cd $DST_REPO/external-storage/ +make push-openebs-provisioner +rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi + +$DST_REPO/external-storage/openebs/ci/travis-ci.sh +rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi + diff --git a/openebs/ci/helm_install_openebs.sh b/openebs/ci/helm_install_openebs.sh new file mode 100755 index 00000000000..ad960045e00 --- /dev/null +++ b/openebs/ci/helm_install_openebs.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +kubectl -n kube-system create sa tiller +kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller +kubectl -n kube-system patch deploy/tiller-deploy -p '{"spec": {"template": {"spec": {"serviceAccountName": "tiller"}}}}' + +#Replace this with logic to wait till helm is initialized +sleep 30 +kubectl get pods --all-namespaces + +helm repo add openebs-charts https://openebs.github.io/charts/ +helm repo update +helm install openebs-charts/openebs --set apiserver.imageTag="0.5.2",apiserver.replicas="1",provisioner.imageTag="ci",provisioner.replicas="1",jiva.replicas="1",rbacEnable="false" + +#Replace this with logic to wait/verify openebs control plane is initialized +sleep 30 +kubectl get pods --all-namespaces -o yaml +kubectl get svc --all-namespaces -o yaml diff --git a/openebs/ci/travis-ci.sh b/openebs/ci/travis-ci.sh new file mode 100755 index 00000000000..bd73e0c81bb --- /dev/null +++ b/openebs/ci/travis-ci.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Copyright 2017 The OpenEBS 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. + +$DST_REPO/external-storage/openebs/ci/helm_install_openebs.sh +rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi diff --git a/openebs/ci/ubuntu-compile-nsenter.sh b/openebs/ci/ubuntu-compile-nsenter.sh new file mode 100755 index 00000000000..397ef46dc0a --- /dev/null +++ b/openebs/ci/ubuntu-compile-nsenter.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +# +# Copyright 2017 The Jaeger 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 -e + +sudo apt-get update +sudo apt-get install libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool +mkdir .tmp || true +wget https://www.kernel.org/pub/linux/utils/util-linux/v2.30/util-linux-2.30.2.tar.gz -qO - | tar -xz -C .tmp/ +cd .tmp/util-linux-2.30.2 && ./autogen.sh && ./configure && make nsenter + From 573f7ba914ed10b0d53d55d6fe02ffc33010723c Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Sun, 11 Feb 2018 23:20:59 +0530 Subject: [PATCH 2/2] make the maya-apiserver-service configurable via ENV OPENEBS_MAYA_SERVICE_NAME can be used to pass the name of the openebs-provisioner name. If the ENV is not present, openebs-provisioner will try to connect with : maya-apiserver-service Signed-off-by: kmova --- openebs/pkg/v1/maya_api.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openebs/pkg/v1/maya_api.go b/openebs/pkg/v1/maya_api.go index 2117fa38df6..da277b8d0bd 100644 --- a/openebs/pkg/v1/maya_api.go +++ b/openebs/pkg/v1/maya_api.go @@ -61,10 +61,16 @@ func (v OpenEBSVolume) GetMayaClusterIP(client kubernetes.Interface) (string, er } glog.Info("OpenEBS volume provisioner namespace ", namespace) + //Fetch the Maya ClusterIP using the Maya API Server Service - sc, err := client.CoreV1().Services(namespace).Get("maya-apiserver-service", metav1.GetOptions{}) + mayaAPIServiceName := os.Getenv("OPENEBS_MAYA_SERVICE_NAME") + if mayaAPIServiceName == "" { + mayaAPIServiceName = "maya-apiserver-service" + } + + sc, err := client.CoreV1().Services(namespace).Get(mayaAPIServiceName, metav1.GetOptions{}) if err != nil { - glog.Errorf("Error getting maya-apiserver IP Address: %v", err) + glog.Errorf("Error getting IP Address for service - %s : %v", mayaAPIServiceName, err) } clusterIP = sc.Spec.ClusterIP