diff --git a/.zuul.yaml b/.zuul.yaml index 83aaf86e..71257698 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -61,12 +61,14 @@ name: openstack-helm-addons-sonobuoy required-projects: - openstack/openstack-helm-infra + - openstack/openstack-helm roles: - zuul: openstack/openstack-helm-infra timeout: 7200 vars: osh_openstack_release: newton zuul_osh_infra_relative_path: ../openstack-helm-infra/ + zuul_osh_relative_path: ../openstack-helm/ nodeset: openstack-helm-ubuntu pre-run: - tools/gate/playbooks/osh-infra-upgrade-host.yaml diff --git a/sonobuoy/templates/bin/_publish_results.sh.tpl b/sonobuoy/templates/bin/_publish_results.sh.tpl new file mode 100644 index 00000000..d23dc1be --- /dev/null +++ b/sonobuoy/templates/bin/_publish_results.sh.tpl @@ -0,0 +1,34 @@ +#!/bin/bash + +{{/* +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. +*/}} + +set -xe + +while [ "$(ls -l $RESULTS_DIR/*.tar.gz | wc -l)" -eq 0 ]; do + sleep 5 +done + +file_name=$(ls $RESULTS_DIR/*.tar.gz | xargs -n1 basename) +prefixed_file_name={{ .Values.conf.swift.object_name_prefix }}$file_name + +openstack container create {{ .Values.conf.swift.container_name }} +openstack container show {{ .Values.conf.swift.container_name }} + +openstack object create --name $prefixed_file_name {{ .Values.conf.swift.container_name }} $RESULTS_DIR/$file_name +openstack object show {{ .Values.conf.swift.container_name }} $prefixed_file_name + +swift post {{ .Values.conf.swift.container_name }} $prefixed_file_name -H \"X-Delete-After:{{ .Values.conf.swift.delete_objects_after_seconds }}\" diff --git a/sonobuoy/templates/configmap-bin.yaml b/sonobuoy/templates/configmap-bin.yaml index 7a04f7c6..e34c7671 100644 --- a/sonobuoy/templates/configmap-bin.yaml +++ b/sonobuoy/templates/configmap-bin.yaml @@ -22,6 +22,10 @@ kind: ConfigMap metadata: name: sonobuoy-bin data: + ks-user.sh: | +{{- include "helm-toolkit.scripts.keystone_user" $envAll | indent 4 }} + publish_results.sh: | +{{ tuple "bin/_publish_results.sh.tpl" $envAll | include "helm-toolkit.utils.template" | indent 4 }} run_master.sh: | {{ tuple "bin/_run_master.sh.tpl" $envAll | include "helm-toolkit.utils.template" | indent 4 }} {{- end }} diff --git a/sonobuoy/templates/job-ks-user.yaml b/sonobuoy/templates/job-ks-user.yaml new file mode 100644 index 00000000..b6313edd --- /dev/null +++ b/sonobuoy/templates/job-ks-user.yaml @@ -0,0 +1,20 @@ +{{/* +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. +*/}} + +{{- if .Values.manifests.job_ks_user }} +{{- $ksUserJob := dict "envAll" . "serviceName" "sonobuoy" -}} +{{ $ksUserJob | include "helm-toolkit.manifests.job_ks_user" }} +{{- end }} diff --git a/sonobuoy/templates/pod-api.yaml b/sonobuoy/templates/pod-api.yaml index 21dee2f2..390e27e6 100644 --- a/sonobuoy/templates/pod-api.yaml +++ b/sonobuoy/templates/pod-api.yaml @@ -58,6 +58,8 @@ metadata: spec: nodeSelector: {{ .Values.labels.api.node_selector_key }}: {{ .Values.labels.api.node_selector_value}} + initContainers: +{{ tuple $envAll "sonobuoy" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} containers: - name: kube-sonobuoy env: @@ -79,6 +81,23 @@ spec: mountPath: /run_master.sh subPath: run_master.sh readOnly: true + - name: results-publisher +{{ tuple $envAll "results_publisher" | include "helm-toolkit.snippets.image" | indent 4 }} + env: +{{- with $env := dict "ksUserSecret" $envAll.Values.secrets.identity.sonobuoy }} +{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 4 }} +{{- end }} + - name: RESULTS_DIR + value: {{ .Values.conf.sonobuoy.ResultsDir }} + command: + - /publish_results.sh + volumeMounts: + - name: sonobuoy-bin + mountPath: /publish_results.sh + subPath: publish_results.sh + readOnly: true + - mountPath: {{ .Values.conf.sonobuoy.ResultsDir }} + name: sonobuoy-output restartPolicy: Never serviceAccountName: {{ $serviceAccountName }} volumes: diff --git a/sonobuoy/templates/secret-keystone.yaml b/sonobuoy/templates/secret-keystone.yaml new file mode 100644 index 00000000..1130faf5 --- /dev/null +++ b/sonobuoy/templates/secret-keystone.yaml @@ -0,0 +1,30 @@ +{{/* +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. +*/}} + +{{- if .Values.manifests.secret_keystone }} +{{- $envAll := . }} +{{- range $key1, $userClass := tuple "admin" "sonobuoy" }} +{{- $secretName := index $envAll.Values.secrets.identity $userClass }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ $secretName }} +type: Opaque +data: +{{- tuple $userClass "internal" $envAll | include "helm-toolkit.snippets.keystone_secret_openrc" | indent 2 -}} +{{- end }} +{{- end }} diff --git a/sonobuoy/values.yaml b/sonobuoy/values.yaml index def42e7f..633f08a3 100644 --- a/sonobuoy/values.yaml +++ b/sonobuoy/values.yaml @@ -14,6 +14,9 @@ images: tags: + dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1 + ks_user: docker.io/openstackhelm/heat:ocata + results_publisher: docker.io/openstackhelm/heat:ocata sonobuoy_api: gcr.io/heptio-images/sonobuoy:v0.11.4 systemd_logs: gcr.io/heptio-images/sonobuoy-plugin-systemd-logs:v0.1 pull_policy: "IfNotPresent" @@ -25,18 +28,82 @@ labels: api: node_selector_key: openstack-control-plane node_selector_value: enabled + job: + node_selector_key: openstack-control-plane + node_selector_value: enabled dependencies: dynamic: {} - static: {} + static: + sonobuoy: + jobs: + - sonobuoy-ks-user + +pod: + resources: + enabled: false + jobs: + ks_user: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "128Mi" + cpu: "2000m" + +secrets: + identity: + admin: sonobuoy-keystone-admin + sonobuoy: sonobuoy-keystone-user + +endpoints: + cluster_domain_suffix: cluster.local + identity: + name: keystone + auth: + admin: + region_name: RegionOne + username: admin + password: password + project_name: admin + user_domain_name: default + project_domain_name: default + sonobuoy: + role: admin + region_name: RegionOne + username: sonobuoy + password: password + project_name: sonobuoy + user_domain_name: sonobuoy + project_domain_name: sonobuoy + hosts: + default: keystone + internal: keystone-api + host_fqdn_override: + default: null + path: + default: /v3 + scheme: + default: http + port: + api: + default: 80 + internal: 5000 manifests: configmap_bin: true configmap_plugins: true + job_ks_user: true pod_api: true secret_etc: true + secret_keystone: true conf: + swift: + container_name: sonobuoy + # delete objects after 1 month (60 * 60 * 24 * 30 seconds) + delete_objects_after_seconds: "2592000" + object_name_prefix: "" sonobuoy: Description: "sonobuoy run for scanner.heptio.com" Version: v0.11.4 diff --git a/tools/gate/playbooks/osh-addons-sonobuoy.yaml b/tools/gate/playbooks/osh-addons-sonobuoy.yaml index dfccce7e..6e1f497b 100644 --- a/tools/gate/playbooks/osh-addons-sonobuoy.yaml +++ b/tools/gate/playbooks/osh-addons-sonobuoy.yaml @@ -1,5 +1,91 @@ - hosts: primary tasks: + - name: Build Charts + shell: | + set -xe; + ./tools/gate/scripts/010-setup-client.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Deploy MariaDB + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_INFRA_PATH: "{{ zuul_osh_infra_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/020-deploy-mariadb.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Deploy RabbitMQ + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_INFRA_PATH: "{{ zuul_osh_infra_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/030-deploy-rabbitmq.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Deploy Memcached + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_INFRA_PATH: "{{ zuul_osh_infra_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/040-deploy-memcached.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Deploy Keystone + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_PATH: "{{ zuul_osh_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/050-deploy-keystone.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Deploy Ceph + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_INFRA_PATH: "{{ zuul_osh_infra_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/080-deploy-ceph.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Activate Ceph Namespace + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_INFRA_PATH: "{{ zuul_osh_infra_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/085-ceph-ns-activate.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Deploy RadosGW + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_INFRA_PATH: "{{ zuul_osh_infra_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/090-radosgw-openstack.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" + - name: Deploy Ingress + environment: + OSH_EXTRA_HELM_ARGS: "{{ zuul_osh_extra_helm_args_relative_path | default('') }}" + OSH_INFRA_PATH: "{{ zuul_osh_infra_relative_path | default('') }}" + zuul_site_mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + shell: | + set -xe; + ./tools/gate/scripts/100-ingress.sh + args: + chdir: "{{ zuul_osh_addons_relative_path | default(zuul.project.src_dir) }}" - name: Install and Test Sonobuoy Chart shell: | set -xe; diff --git a/tools/gate/scripts/080-deploy-ceph.sh b/tools/gate/scripts/080-deploy-ceph.sh new file mode 100755 index 00000000..f14be4d3 --- /dev/null +++ b/tools/gate/scripts/080-deploy-ceph.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +# 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. + +set -xe + +#NOTE: Lint and package chart +: ${OSH_INFRA_PATH:="../openstack-helm-infra"} +for CHART in ceph-mon ceph-osd ceph-client ceph-provisioners; do + make -C ${OSH_INFRA_PATH} "${CHART}" +done + +#NOTE: Deploy command + +: ${OSH_EXTRA_HELM_ARGS:=""} +CEPH_PUBLIC_NETWORK="$($OSH_INFRA_PATH/tools/deployment/multinode/kube-node-subnet.sh)" +CEPH_CLUSTER_NETWORK="$($OSH_INFRA_PATH/tools/deployment/multinode/kube-node-subnet.sh)" +[ -s /tmp/ceph-fs-uuid.txt ] || uuidgen > /tmp/ceph-fs-uuid.txt +CEPH_FS_ID="$(cat /tmp/ceph-fs-uuid.txt)" +#NOTE(portdirect): to use RBD devices with Ubuntu kernels < 4.5 this +# should be set to 'hammer' +. /etc/os-release +if [ "x${ID}" == "xubuntu" ] && \ + [ "$(uname -r | awk -F "." '{ print $2 }')" -lt "5" ]; then + CRUSH_TUNABLES=hammer +else + CRUSH_TUNABLES=null +fi +tee /tmp/ceph.yaml <