From 87f22838f2fb6a0421028248bf6e7e1333a86a54 Mon Sep 17 00:00:00 2001 From: portdirect Date: Thu, 16 Nov 2017 01:10:12 -0500 Subject: [PATCH] Gate: Modularise gate for development use This PS breaks down the gate to enable use as a development aid. Change-Id: I376da8940ed085b7575dd528ec4082f42da1748c --- .zuul.yaml | 7 ++- Makefile | 8 ++- tools/gate/chart-deploys/default.yaml | 61 +++++++++++++++++++ tools/gate/devel/start.sh | 49 +++++++++++---- .../{zuul-pre.yaml => osh-infra-build.yaml} | 30 --------- .../playbooks/osh-infra-deploy-charts.yaml | 35 +++++++++++ .../playbooks/osh-infra-deploy-docker.yaml | 43 +++++++++++++ ...uul-run.yaml => osh-infra-deploy-k8s.yaml} | 21 ++----- tools/gate/playbooks/osh-infra-docker.yaml | 40 ++++++++++++ tools/gate/playbooks/vars.yaml | 48 --------------- tools/image-repo-overides.sh | 3 +- 11 files changed, 235 insertions(+), 110 deletions(-) create mode 100644 tools/gate/chart-deploys/default.yaml rename tools/gate/playbooks/{zuul-pre.yaml => osh-infra-build.yaml} (68%) create mode 100644 tools/gate/playbooks/osh-infra-deploy-charts.yaml create mode 100644 tools/gate/playbooks/osh-infra-deploy-docker.yaml rename tools/gate/playbooks/{zuul-run.yaml => osh-infra-deploy-k8s.yaml} (78%) create mode 100644 tools/gate/playbooks/osh-infra-docker.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 3aaaab2bb..0ae2ac5dd 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -96,8 +96,11 @@ - job: name: openstack-helm-infra - pre-run: tools/gate/playbooks/zuul-pre.yaml - run: tools/gate/playbooks/zuul-run.yaml + pre-run: + - tools/gate/playbooks/osh-infra-deploy-docker.yaml + - tools/gate/playbooks/osh-infra-build.yaml + - tools/gate/playbooks/osh-infra-deploy-k8s.yaml + run: tools/gate/playbooks/osh-infra-deploy-charts.yaml - job: name: openstack-helm-infra-ubuntu diff --git a/Makefile b/Makefile index 599b1a354..bb61f2ad5 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,8 @@ TASK := build EXCLUDES := helm-toolkit doc tests tools logs CHARTS := helm-toolkit $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.))) +.PHONY: $(EXCLUDES) $(CHARTS) + all: $(CHARTS) $(CHARTS): @@ -50,4 +52,8 @@ clean: pull-all-images: @./tools/pull-images.sh -.PHONY: $(EXCLUDES) $(CHARTS) +dev-deploy: + @./tools/gate/devel/start.sh $(filter-out $@,$(MAKECMDGOALS)) + +%: + @: diff --git a/tools/gate/chart-deploys/default.yaml b/tools/gate/chart-deploys/default.yaml new file mode 100644 index 000000000..4987ac4ef --- /dev/null +++ b/tools/gate/chart-deploys/default.yaml @@ -0,0 +1,61 @@ +# Copyright 2017 The Openstack-Helm 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. + +chart_groups: + - name: docker_registry + timeout: 600 + charts: + - docker_registry_nfs_provisioner + - docker_registry_redis + - docker_registry + +charts: + docker_registry_nfs_provisioner: + chart_name: nfs-provisioner + release: docker-registry-nfs-provisioner + namespace: docker-registry + upgrade: + pre: + delete: + - name: docker-bootstrap + type: job + labels: + application: docker + component: bootstrap + values: + labels: + node_selector_key: openstack-helm-node-class + node_selector_value: primary + storageclass: + name: openstack-helm-bootstrap + + docker_registry_redis: + chart_name: redis + release: docker-registry-redis + namespace: docker-registry + values: + labels: + node_selector_key: openstack-helm-node-class + node_selector_value: primary + + docker_registry: + chart_name: registry + release: docker-registry + namespace: docker-registry + values: + labels: + node_selector_key: openstack-helm-node-class + node_selector_value: primary + volume: + class_name: openstack-helm-bootstrap diff --git a/tools/gate/devel/start.sh b/tools/gate/devel/start.sh index 133bb0b64..2fc43d204 100755 --- a/tools/gate/devel/start.sh +++ b/tools/gate/devel/start.sh @@ -16,7 +16,10 @@ set -ex : ${WORK_DIR:="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../../.."} -export MODE=${1:-"local"} +export DEPLOY=${1:-"full"} +export MODE=${2:-"local"} +export INVENTORY=${WORK_DIR}/tools/gate/devel/${MODE}-inventory.yaml +export VARS=${WORK_DIR}/tools/gate/devel/${MODE}-vars.yaml function ansible_install { cd /tmp @@ -28,7 +31,8 @@ function ansible_install { python-pip \ libssl-dev \ python-dev \ - build-essential + build-essential \ + jq elif [ "x$ID" == "xcentos" ]; then sudo yum install -y \ epel-release @@ -36,22 +40,41 @@ function ansible_install { python-pip \ python-devel \ redhat-rpm-config \ - gcc + gcc \ + curl + sudo curl -L -o /usr/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 + sudo chmod +x /usr/bin/jq elif [ "x$ID" == "xfedora" ]; then sudo dnf install -y \ python-devel \ redhat-rpm-config \ - gcc + gcc \ + jq fi sudo -H pip install --no-cache-dir --upgrade pip sudo -H pip install --no-cache-dir --upgrade setuptools sudo -H pip install --no-cache-dir --upgrade pyopenssl - sudo -H pip install --no-cache-dir ansible - sudo -H pip install --no-cache-dir ara - sudo -H pip install --no-cache-dir yq + sudo -H pip install --no-cache-dir \ + ansible \ + ara \ + yq } -ansible_install + +if [ "x${DEPLOY}" == "xsetup-host" ]; then + ansible_install + PLAYBOOKS="osh-infra-docker" +elif [ "x${DEPLOY}" == "xk8s" ]; then + PLAYBOOKS="osh-infra-build osh-infra-deploy-k8s" +elif [ "x${DEPLOY}" == "xcharts" ]; then + PLAYBOOKS="osh-infra-deploy-charts" +elif [ "x${DEPLOY}" == "xfull" ]; then + ansible_install + PLAYBOOKS="osh-infra-docker osh-infra-build osh-infra-deploy-k8s osh-infra-deploy-charts" +else + echo "Unknown Deploy Option Selected" + exit 1 +fi cd ${WORK_DIR} export ANSIBLE_CALLBACK_PLUGINS="$(python -c 'import os,ara; print(os.path.dirname(ara.__file__))')/plugins/callbacks" @@ -68,7 +91,9 @@ function dump_logs () { } trap 'dump_logs "$?"' ERR -INVENTORY=${WORK_DIR}/tools/gate/devel/${MODE}-inventory.yaml -VARS=${WORK_DIR}/tools/gate/devel/${MODE}-vars.yaml -ansible-playbook ${WORK_DIR}/tools/gate/playbooks/zuul-pre.yaml -i ${INVENTORY} --extra-vars=@${VARS} --extra-vars "work_dir=${WORK_DIR}" -ansible-playbook ${WORK_DIR}/tools/gate/playbooks/zuul-run.yaml -i ${INVENTORY} --extra-vars=@${VARS} --extra-vars "work_dir=${WORK_DIR}" +for PLAYBOOK in ${PLAYBOOKS}; do + ansible-playbook ${WORK_DIR}/tools/gate/playbooks/${PLAYBOOK}.yaml \ + -i ${INVENTORY} \ + --extra-vars=@${VARS} \ + --extra-vars "work_dir=${WORK_DIR}" +done diff --git a/tools/gate/playbooks/zuul-pre.yaml b/tools/gate/playbooks/osh-infra-build.yaml similarity index 68% rename from tools/gate/playbooks/zuul-pre.yaml rename to tools/gate/playbooks/osh-infra-build.yaml index 8c7b5ee9e..4398e1e18 100644 --- a/tools/gate/playbooks/zuul-pre.yaml +++ b/tools/gate/playbooks/osh-infra-build.yaml @@ -12,18 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- hosts: all - vars_files: - - vars.yaml - vars: - work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" - gather_facts: False - become: yes - roles: - - deploy-python - tags: - - deploy-python - - hosts: primary vars_files: - vars.yaml @@ -35,24 +23,6 @@ tags: - build-helm-packages -- hosts: all - vars_files: - - vars.yaml - vars: - work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" - gather_facts: True - become: yes - roles: - - setup-firewall - - deploy-python-pip - - deploy-docker - - deploy-yq - tags: - - setup-firewall - - deploy-python-pip - - deploy-docker - - deploy-yq - - hosts: all vars_files: - vars.yaml diff --git a/tools/gate/playbooks/osh-infra-deploy-charts.yaml b/tools/gate/playbooks/osh-infra-deploy-charts.yaml new file mode 100644 index 000000000..bc66ca0b7 --- /dev/null +++ b/tools/gate/playbooks/osh-infra-deploy-charts.yaml @@ -0,0 +1,35 @@ +# Copyright 2017 The Openstack-Helm 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. + +- hosts: primary + vars_files: + - vars.yaml + vars: + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" + gather_facts: True + roles: + - build-helm-packages + tags: + - build-helm-packages + +- hosts: primary + vars_files: + - vars.yaml + - ../chart-deploys/default.yaml + vars: + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" + roles: + - deploy-helm-packages + tags: + - deploy-helm-packages diff --git a/tools/gate/playbooks/osh-infra-deploy-docker.yaml b/tools/gate/playbooks/osh-infra-deploy-docker.yaml new file mode 100644 index 000000000..4c5432453 --- /dev/null +++ b/tools/gate/playbooks/osh-infra-deploy-docker.yaml @@ -0,0 +1,43 @@ +# Copyright 2017 The Openstack-Helm 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. + +- hosts: all + vars_files: + - vars.yaml + vars: + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" + gather_facts: False + become: yes + roles: + - deploy-python + tags: + - deploy-python + +- hosts: all + vars_files: + - vars.yaml + vars: + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" + gather_facts: True + become: yes + roles: + - setup-firewall + - deploy-python-pip + - deploy-docker + - deploy-yq + tags: + - setup-firewall + - deploy-python-pip + - deploy-docker + - deploy-yq diff --git a/tools/gate/playbooks/zuul-run.yaml b/tools/gate/playbooks/osh-infra-deploy-k8s.yaml similarity index 78% rename from tools/gate/playbooks/zuul-run.yaml rename to tools/gate/playbooks/osh-infra-deploy-k8s.yaml index d301fa03d..8daa337e3 100644 --- a/tools/gate/playbooks/zuul-run.yaml +++ b/tools/gate/playbooks/osh-infra-deploy-k8s.yaml @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -- hosts: all +- hosts: primary vars_files: - vars.yaml vars: work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" + gather_facts: True roles: - - clean-host + - build-helm-packages tags: - - clean-host + - build-helm-packages - hosts: primary vars_files: @@ -30,7 +31,7 @@ roles: - deploy-kubeadm-aio-master tags: - - deploy-kubeadm-aio-master + - deploy-kube-master - hosts: nodes vars_files: @@ -40,14 +41,4 @@ roles: - deploy-kubeadm-aio-node tags: - - deploy-kubeadm-aio-node - -- hosts: primary - vars_files: - - vars.yaml - vars: - work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" - roles: - - deploy-helm-packages - tags: - - deploy-helm-packages + - deploy-kube-nodes diff --git a/tools/gate/playbooks/osh-infra-docker.yaml b/tools/gate/playbooks/osh-infra-docker.yaml new file mode 100644 index 000000000..f718dfc3b --- /dev/null +++ b/tools/gate/playbooks/osh-infra-docker.yaml @@ -0,0 +1,40 @@ +# Copyright 2017 The Openstack-Helm 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. + +- hosts: all + vars_files: + - vars.yaml + vars: + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" + gather_facts: False + become: yes + roles: + - deploy-python + tags: + - python + +- hosts: all + vars_files: + - vars.yaml + vars: + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" + gather_facts: True + become: yes + roles: + - setup-firewall + - deploy-python-pip + - deploy-docker + - deploy-yq + tags: + - docker diff --git a/tools/gate/playbooks/vars.yaml b/tools/gate/playbooks/vars.yaml index 7ec82ea18..25b1255c0 100644 --- a/tools/gate/playbooks/vars.yaml +++ b/tools/gate/playbooks/vars.yaml @@ -51,51 +51,3 @@ nodes: value: enabled - name: ceph-rgw value: enabled - -chart_groups: - - name: docker_registry - timeout: 600 - charts: - - docker_registry_nfs_provisioner - - docker_registry_redis - - docker_registry - -charts: - docker_registry_nfs_provisioner: - chart_name: nfs-provisioner - release: docker-registry-nfs-provisioner - namespace: docker-registry - upgrade: - pre: - delete: - - name: docker-bootstrap - type: job - labels: - application: docker - component: bootstrap - values: - labels: - node_selector_key: openstack-helm-node-class - node_selector_value: primary - storageclass: - name: openstack-helm-bootstrap - - docker_registry_redis: - chart_name: redis - release: docker-registry-redis - namespace: docker-registry - values: - labels: - node_selector_key: openstack-helm-node-class - node_selector_value: primary - - docker_registry: - chart_name: registry - release: docker-registry - namespace: docker-registry - values: - labels: - node_selector_key: openstack-helm-node-class - node_selector_value: primary - volume: - class_name: openstack-helm-bootstrap diff --git a/tools/image-repo-overides.sh b/tools/image-repo-overides.sh index a62164f70..8fe0ad527 100755 --- a/tools/image-repo-overides.sh +++ b/tools/image-repo-overides.sh @@ -15,8 +15,7 @@ # limitations under the License. KUBE_VERSION=$(yq -r '.version.kubernetes' ./tools/gate/playbooks/vars.yaml) -KUBE_IMAGES="gcr.io/google_containers/hyperkube-amd64:${KUBE_VERSION} -gcr.io/google_containers/kube-apiserver-amd64:${KUBE_VERSION} +KUBE_IMAGES="gcr.io/google_containers/kube-apiserver-amd64:${KUBE_VERSION} gcr.io/google_containers/kube-controller-manager-amd64:${KUBE_VERSION} gcr.io/google_containers/kube-proxy-amd64:${KUBE_VERSION} gcr.io/google_containers/kube-scheduler-amd64:${KUBE_VERSION}