From f4a0b57c9f4c71347a647e402792afb4f12eab0e Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Mon, 7 May 2018 10:59:04 -0500 Subject: [PATCH] Nova: Add initial cell v2 setup job This PS adds a job to run post initial deployment to ensure at least one node is added to the cell upon deploy. Change-Id: I300ba9760bdcfcb01f17d731b0cbbc6d5d0bce61 --- nova/templates/bin/_cell-setup-init.sh.tpl | 24 ++++++ nova/templates/configmap-bin.yaml | 2 + nova/templates/cron-job-cell-setup.yaml | 2 +- nova/templates/job-cell-setup.yaml | 88 ++++++++++++++++++++++ nova/values.yaml | 2 + 5 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 nova/templates/bin/_cell-setup-init.sh.tpl create mode 100644 nova/templates/job-cell-setup.yaml diff --git a/nova/templates/bin/_cell-setup-init.sh.tpl b/nova/templates/bin/_cell-setup-init.sh.tpl new file mode 100644 index 0000000000..208196a508 --- /dev/null +++ b/nova/templates/bin/_cell-setup-init.sh.tpl @@ -0,0 +1,24 @@ +#!/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 -ex + +until openstack compute service list --service nova-compute -f value -c State | grep -q "^up$" ;do + echo "Waiting for Nova Compute processes to register" + sleep 10 +done diff --git a/nova/templates/configmap-bin.yaml b/nova/templates/configmap-bin.yaml index efb24cc67a..46f3f46bc3 100644 --- a/nova/templates/configmap-bin.yaml +++ b/nova/templates/configmap-bin.yaml @@ -79,6 +79,8 @@ data: {{ tuple "bin/_ssh-start.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} cell-setup.sh: | {{ tuple "bin/_cell-setup.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + cell-setup-init.sh: | +{{ tuple "bin/_cell-setup-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} rabbit-init.sh: | {{- include "helm-toolkit.scripts.rabbit_init" . | indent 4 }} {{- end }} diff --git a/nova/templates/cron-job-cell-setup.yaml b/nova/templates/cron-job-cell-setup.yaml index 26f5701d06..02b2d99eeb 100644 --- a/nova/templates/cron-job-cell-setup.yaml +++ b/nova/templates/cron-job-cell-setup.yaml @@ -18,7 +18,7 @@ limitations under the License. {{- $envAll := . }} {{- $dependencies := .Values.dependencies.static.cell_setup }} -{{- $serviceAccountName := "nova-cell-setup" }} +{{- $serviceAccountName := "nova-cell-setup-cron" }} {{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- apiVersion: batch/v1beta1 diff --git a/nova/templates/job-cell-setup.yaml b/nova/templates/job-cell-setup.yaml new file mode 100644 index 0000000000..5222ea08ed --- /dev/null +++ b/nova/templates/job-cell-setup.yaml @@ -0,0 +1,88 @@ +{{/* +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_cell_setup }} +{{- $envAll := . }} +{{- $dependencies := .Values.dependencies.static.cell_setup }} + +{{- $serviceAccountName := "nova-cell-setup" }} +{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: nova-cell-setup +spec: + template: + metadata: + labels: +{{ tuple $envAll "nova" "cell-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} + spec: + serviceAccountName: {{ $serviceAccountName }} + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} + initContainers: +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + - name: nova-cell-setup-init + image: {{ .Values.images.tags.nova_cell_setup_init }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.cell_setup | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + env: +{{- with $env := dict "ksUserSecret" $envAll.Values.secrets.identity.admin }} +{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 12 }} +{{- end }} + command: + - /tmp/cell-setup-init.sh + volumeMounts: + - name: nova-bin + mountPath: /tmp/cell-setup-init.sh + subPath: cell-setup-init.sh + readOnly: true + containers: + - name: nova-cell-setup + image: {{ .Values.images.tags.nova_cell_setup }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.cell_setup | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + command: + - /tmp/cell-setup.sh + volumeMounts: + - name: nova-bin + mountPath: /tmp/cell-setup.sh + subPath: cell-setup.sh + readOnly: true + - name: etcnova + mountPath: /etc/nova + - name: nova-etc + mountPath: /etc/nova/nova.conf + subPath: nova.conf + readOnly: true + - name: nova-etc + mountPath: /etc/nova/policy.yaml + subPath: policy.yaml + readOnly: true + volumes: + - name: etcnova + emptyDir: {} + - name: nova-etc + configMap: + name: nova-etc + defaultMode: 0444 + - name: nova-bin + configMap: + name: nova-bin + defaultMode: 0555 +{{- end }} diff --git a/nova/values.yaml b/nova/values.yaml index 0cefa66964..b7e8abdd8d 100644 --- a/nova/values.yaml +++ b/nova/values.yaml @@ -71,6 +71,7 @@ images: ks_endpoints: docker.io/openstackhelm/heat:newton nova_api: docker.io/openstackhelm/nova:newton nova_cell_setup: docker.io/openstackhelm/nova:newton + nova_cell_setup_init: docker.io/openstackhelm/heat:newton nova_compute: docker.io/openstackhelm/nova:newton nova_compute_ironic: 'docker.io/kolla/ubuntu-source-nova-compute-ironic:3.0.3' nova_compute_ssh: docker.io/openstackhelm/nova:newton @@ -1654,6 +1655,7 @@ manifests: job_ks_placement_endpoints: true job_ks_placement_service: true job_ks_placement_user: true + job_cell_setup: true pdb_metadata: true pdb_placement: true pdb_osapi: true