From 67d80770e680528e3f72d5e42e8c500b5ec6f9cc Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Wed, 3 May 2017 19:10:48 -0500 Subject: [PATCH] Gate: Refactor and setup for integration gating This PS tidies up the gate and introduces the intial framework for integration gating. Change-Id: I0bbdfa2088e9ebbe86640c79df4d8b716d9a9705 --- doc/source/install/all-in-one.rst | 36 +++++----- tools/gate/basic_launch.sh | 35 ++++++++++ tools/gate/funcs/helm.sh | 62 ++++++++++++++++ tools/gate/funcs/kube.sh | 70 +++++++++++++++++++ tools/gate/kubeadm_aio.sh | 20 ++++++ tools/gate/setup_gate.sh | 56 ++++----------- tools/overrides/mvp/README.rst | 15 ++++ .../overrides/mvp/glance.yaml | 0 .../overrides/mvp/neutron.yaml | 0 .../overrides/mvp/nova.yaml | 0 10 files changed, 234 insertions(+), 60 deletions(-) create mode 100755 tools/gate/basic_launch.sh create mode 100755 tools/gate/funcs/helm.sh create mode 100755 tools/gate/funcs/kube.sh create mode 100755 tools/gate/kubeadm_aio.sh create mode 100644 tools/overrides/mvp/README.rst rename glance/_values-mvp.yaml => tools/overrides/mvp/glance.yaml (100%) rename neutron/_values-mvp.yaml => tools/overrides/mvp/neutron.yaml (100%) rename nova/_values-mvp.yaml => tools/overrides/mvp/nova.yaml (100%) diff --git a/doc/source/install/all-in-one.rst b/doc/source/install/all-in-one.rst index 902275bdac..ac9bd03f9a 100644 --- a/doc/source/install/all-in-one.rst +++ b/doc/source/install/all-in-one.rst @@ -17,7 +17,7 @@ Setup etc/hosts --------------- :: - + #Replace eth0 with your interface name LOCAL_IP=$(ip addr | awk '/inet/ && /eth0/{sub(/\/.*$/,"",$2); print $2}') cat << EOF | sudo tee -a /etc/hosts @@ -31,12 +31,12 @@ Install the latest versions of Docker, Network File System, Git & Make :: - sudo apt-get update -y - sudo apt-get install -y --no-install-recommends -qq \ - docker.io \ - nfs-common \ - git \ - make + sudo apt-get update -y + sudo apt-get install -y --no-install-recommends -qq \ + docker.io \ + nfs-common \ + git \ + make Kubectl ------- @@ -45,13 +45,13 @@ Download and install kubectl, the command line interface for running commands ag :: - KUBE_VERSION=v1.6.0 - HELM_VERSION=v2.3.0 - TMP_DIR=$(mktemp -d) - + KUBE_VERSION=v1.6.0 + HELM_VERSION=v2.3.0 + TMP_DIR=$(mktemp -d) + curl -sSL https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl -o ${TMP_DIR}/kubectl - chmod +x ${TMP_DIR}/kubectl - sudo mv ${TMP_DIR}/kubectl /usr/local/bin/kubectl + chmod +x ${TMP_DIR}/kubectl + sudo mv ${TMP_DIR}/kubectl /usr/local/bin/kubectl Helm ---- @@ -61,8 +61,8 @@ Download and install Helm, the package manager for Kubernetes :: curl -sSL https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -zxv --strip-components=1 -C ${TMP_DIR} - sudo mv ${TMP_DIR}/helm /usr/local/bin/helm - rm -rf ${TMP_DIR} + sudo mv ${TMP_DIR}/helm /usr/local/bin/helm + rm -rf ${TMP_DIR} OpenStack-Helm ============== @@ -145,7 +145,7 @@ In the below examples the default values that would be used in a production-like :: - helm install --name=glance local/glance --namespace=openstack --values=./glance/_values-mvp.yaml - helm install --name=nova local/nova --namespace=openstack --values=./nova/_values-mvp.yaml --set=conf.nova.libvirt.nova.conf.virt_type=qemu - helm install --name=neutron local/neutron --namespace=openstack --values=./neutron/_values-mvp.yaml + helm install --name=glance local/glance --namespace=openstack --values=./tools/overrides/mvp/neutron.yaml + helm install --name=nova local/nova --namespace=openstack --values=./tools/overrides/mvp/nova.yaml --set=conf.nova.libvirt.nova.conf.virt_type=qemu + helm install --name=neutron local/neutron --namespace=openstack --values=./tools/overrides/mvp/neutron.yaml helm install --name=horizon local/horizon --namespace=openstack --set=network.enable_node_port=true diff --git a/tools/gate/basic_launch.sh b/tools/gate/basic_launch.sh new file mode 100755 index 0000000000..2c9d1fb204 --- /dev/null +++ b/tools/gate/basic_launch.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# 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 -ex + +source ${WORK_DIR}/tools/gate/funcs/helm.sh +source ${WORK_DIR}/tools/gate/funcs/kube.sh + +helm_build + +helm search + +helm install local/mariadb --name=mariadb --namespace=openstack +helm install local/memcached --name=memcached --namespace=openstack +helm install local/etcd --name=etcd-rabbitmq --namespace=openstack +helm install local/rabbitmq --name=rabbitmq --namespace=openstack +kube_wait_for_pods openstack 600 + +helm install local/keystone --name=keystone --namespace=openstack +kube_wait_for_pods openstack 240 + +helm install local/glance --name=glance --namespace=openstack --values=${WORK_DIR}/tools/overrides/glance.yaml +helm install local/nova --name=nova --namespace=openstack --values=${WORK_DIR}/tools/overrides/nova.yaml --set=conf.nova.libvirt.nova.conf.virt_type=qemu +helm install local/neutron --name=neutron --namespace=openstack --values=${WORK_DIR}/tools/overrides/neutron.yaml +kube_wait_for_pods openstack 600 diff --git a/tools/gate/funcs/helm.sh b/tools/gate/funcs/helm.sh new file mode 100755 index 0000000000..1583cddd14 --- /dev/null +++ b/tools/gate/funcs/helm.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# 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 + +function helm_install { + TMP_DIR=$(mktemp -d) + sudo apt-get update -y + sudo apt-get install -y --no-install-recommends -qq \ + git \ + make \ + curl \ + ca-certificates + + # install helm + curl -sSL https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -zxv --strip-components=1 -C ${TMP_DIR} + sudo mv ${TMP_DIR}/helm /usr/local/bin/helm + rm -rf ${TMP_DIR} +} + +function helm_serve { + if [[ -d "$HOME/.helm" ]]; then + echo ".helm directory found" + else + helm init --client-only + fi + if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then + helm serve & > /dev/null + while [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; do + sleep 1 + echo "Waiting for Helm Repository" + done + else + echo "Helm serve already running" + fi + + if helm repo list | grep -q "^stable" ; then + helm repo remove stable + fi + + helm repo add local http://localhost:8879/charts + +} + +function helm_lint { + make build-helm-toolkit -C ${WORK_DIR} + make TASK=lint -C ${WORK_DIR} +} + +function helm_build { + make TASK=build -C ${WORK_DIR} +} diff --git a/tools/gate/funcs/kube.sh b/tools/gate/funcs/kube.sh new file mode 100755 index 0000000000..8e8f4989e5 --- /dev/null +++ b/tools/gate/funcs/kube.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# 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 + +function kube_wait_for_pods { + # From Kolla-Kubernetes, orginal authors Kevin Fox & Serguei Bezverkhi + # Default wait timeout is 180 seconds + set +x + end=$(date +%s) + if [ x$2 != "x" ]; then + end=$((end + $2)) + else + end=$((end + 180)) + fi + while true; do + kubectl get pods --namespace=$1 -o json | jq -r \ + '.items[].status.phase' | grep Pending > /dev/null && \ + PENDING=True || PENDING=False + query='.items[]|select(.status.phase=="Running")' + query="$query|.status.containerStatuses[].ready" + kubectl get pods --namespace=$1 -o json | jq -r "$query" | \ + grep false > /dev/null && READY="False" || READY="True" + kubectl get jobs -o json --namespace=$1 | jq -r \ + '.items[] | .spec.completions == .status.succeeded' | \ + grep false > /dev/null && JOBR="False" || JOBR="True" + [ $PENDING == "False" -a $READY == "True" -a $JOBR == "True" ] && \ + break || true + sleep 1 + now=$(date +%s) + [ $now -gt $end ] && echo containers failed to start. && \ + kubectl get pods --namespace $1 && exit -1 + done + set -x +} + +function kubeadm_aio_reqs_install { + TMP_DIR=$(mktemp -d) + sudo apt-get update -y + sudo apt-get install -y --no-install-recommends -qq \ + docker.io \ + nfs-common \ + jq + + curl -sSL https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl -o ${TMP_DIR}/kubectl + chmod +x ${TMP_DIR}/kubectl + sudo mv ${TMP_DIR}/kubectl /usr/local/bin/kubectl +} + +function kubeadm_aio_build { + sudo docker build --pull -t ${KUBEADM_IMAGE} tools/kubeadm-aio +} + +function kubeadm_aio_launch { + ${WORK_DIR}/tools/kubeadm-aio/kubeadm-aio-launcher.sh + mkdir -p ${HOME}/.kube + cat ${KUBECONFIG} > ${HOME}/.kube/config + kube_wait_for_pods kube-system 240 + kube_wait_for_pods default 240 +} diff --git a/tools/gate/kubeadm_aio.sh b/tools/gate/kubeadm_aio.sh new file mode 100755 index 0000000000..ccd4379ecd --- /dev/null +++ b/tools/gate/kubeadm_aio.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# 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 -ex + +source ${WORK_DIR}/tools/gate/funcs/kube.sh + +kubeadm_aio_reqs_install +kubeadm_aio_build +kubeadm_aio_launch diff --git a/tools/gate/setup_gate.sh b/tools/gate/setup_gate.sh index e6f85ad952..4df87ff08c 100755 --- a/tools/gate/setup_gate.sh +++ b/tools/gate/setup_gate.sh @@ -13,49 +13,21 @@ # limitations under the License. set -ex -HELM_VERSION=${2:-v2.3.0} -WORK_DIR=$(pwd) +export HELM_VERSION=${2:-v2.3.0} +export KUBE_VERSION=${3:-v1.6.0} +export KUBECONFIG=${HOME}/.kubeadm-aio/admin.conf +export KUBEADM_IMAGE=openstack-helm/kubeadm-aio:v1.6 -function helm_install { - TMP_DIR=$(mktemp -d) - sudo apt-get update -y - sudo apt-get install -y --no-install-recommends -qq \ - git \ - make \ - curl - - # install helm - curl -sSL https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -zxv --strip-components=1 -C ${TMP_DIR} - sudo mv ${TMP_DIR}/helm /usr/local/bin/helm - rm -rf ${TMP_DIR} -} - -function helm_lint { - if [[ -d "$HOME/.helm" ]]; then - echo ".helm directory found" - else - helm init --client-only - fi - if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then - helm serve & > /dev/null - while [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; do - sleep 1 - echo "Waiting for Helm Repository" - done - else - echo "Helm serve already running" - fi - - if [[ -f "$HOME/.helm/repository/stable/index.yaml" ]]; then - helm repo remove stable - fi - if [[ -z $(-f "$HOME/.helm/repository/local/index.yaml") ]]; then - helm repo add local http://localhost:8879/charts - fi - - make build-helm-toolkit -C ${WORK_DIR} - make TASK=lint -C ${WORK_DIR} -} +export WORK_DIR=$(pwd) +source ${WORK_DIR}/tools/gate/funcs/helm.sh helm_install +helm_serve helm_lint + +if [ "x$INTEGRATION" == "xAIO" ]; then + bash ${WORK_DIR}/tools/gate/kubeadm_aio.sh + if [ "x$INTEGRATION_TYPE" == "xbasic" ]; then + bash ${WORK_DIR}/tools/gate/basic_launch.sh + fi +fi diff --git a/tools/overrides/mvp/README.rst b/tools/overrides/mvp/README.rst new file mode 100644 index 0000000000..0a49120659 --- /dev/null +++ b/tools/overrides/mvp/README.rst @@ -0,0 +1,15 @@ +============================ +OpenStack-Helm MVP Overrides +============================ + +The project specific overrides in this directory allow you to reduce the default +resilience of OpenStack-Helm, by turning off HA of the Neutron Agents. +Additionally the default distributed storage backend, Ceph, is disabled and +replaced by local storage for OpenStack components. + +These changed are made to achieve these goals: + * Demonstrating how values can be set and defined within OpenStack-Helm + * Allowing OpenStack-Helm to run on a single node for: + * Development + * Demonstration + * Basic integration pipelines in a CI System diff --git a/glance/_values-mvp.yaml b/tools/overrides/mvp/glance.yaml similarity index 100% rename from glance/_values-mvp.yaml rename to tools/overrides/mvp/glance.yaml diff --git a/neutron/_values-mvp.yaml b/tools/overrides/mvp/neutron.yaml similarity index 100% rename from neutron/_values-mvp.yaml rename to tools/overrides/mvp/neutron.yaml diff --git a/nova/_values-mvp.yaml b/tools/overrides/mvp/nova.yaml similarity index 100% rename from nova/_values-mvp.yaml rename to tools/overrides/mvp/nova.yaml