Merge "Nova: Update cell and db management"

This commit is contained in:
Zuul 2018-05-03 20:57:04 +00:00 committed by Gerrit Code Review
commit de72d74ae6
5 changed files with 130 additions and 76 deletions

View File

@ -18,4 +18,11 @@ limitations under the License.
set -ex
nova-manage cell_v2 simple_cell_setup
NOVA_VERSION=$(nova-manage --version 2>&1 > /dev/null)
# NOTE(portdirect): check if nova fully supports cells v2, and manage
# accordingly. Support was complete in ocata (V14.x.x).
if [ "${NOVA_VERSION%%.*}" -gt "14" ]; then
nova-manage cell_v2 discover_hosts --verbose
fi

View File

@ -18,6 +18,30 @@ limitations under the License.
set -ex
nova-manage db sync
NOVA_VERSION=$(nova-manage --version 2>&1 > /dev/null)
function manage_cells () {
# NOTE(portdirect): check if nova fully supports cells v2, and manage
# accordingly. Support was complete in ocata (V14.x.x).
if [ "${NOVA_VERSION%%.*}" -gt "14" ]; then
nova-manage cell_v2 map_cell0
nova-manage cell_v2 list_cells | grep -q " cell1 " || \
nova-manage cell_v2 create_cell --name=cell1 --verbose
fi
}
# NOTE(portdirect): if the db has been populated we should setup cells if
# required, otherwise we should poulate the api db, and then setup cells.
if [ "$(nova-manage api_db version)" -gt "0" ]; then
manage_cells
nova-manage api_db sync
else
nova-manage api_db sync
manage_cells
fi
nova-manage db sync
nova-manage db online_data_migrations
echo 'Finished DB migrations'

View File

@ -0,0 +1,82 @@
{{/*
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.cron_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/v1beta1
kind: CronJob
metadata:
name: nova-cell-setup
spec:
schedule: {{ .Values.jobs.cell_setup.cron | quote }}
successfulJobsHistoryLimit: {{ .Values.jobs.cell_setup.history.success }}
failedJobsHistoryLimit: {{ .Values.jobs.cell_setup.history.failed }}
concurrencyPolicy: Forbid
jobTemplate:
metadata:
labels:
{{ tuple $envAll "nova" "cell-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec:
template:
metadata:
labels:
{{ tuple $envAll "nova" "cell-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 12 }}
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 12 }}
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 14 }}
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 }}

View File

@ -1,73 +0,0 @@
{{/*
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 }}
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 }}

View File

@ -85,6 +85,15 @@ images:
nova_spiceproxy_assets: 'docker.io/kolla/ubuntu-source-nova-spicehtml5proxy:3.0.3'
test: 'docker.io/kolla/ubuntu-source-rally:4.0.0'
jobs:
# NOTE(portdirect): When using cells new nodes will be added to the cell on the hour by default.
# TODO(portdirect): Add a post-start action to nova compute pods that registers themselves.
cell_setup:
cron: "0 */1 * * *"
history:
success: 3
failed: 1
bootstrap:
enabled: true
ks_user: admin
@ -252,6 +261,11 @@ dependencies:
service: identity
- endpoint: internal
service: compute
pod:
- requireSameNode: false
labels:
application: nova
component: compute
compute:
pod:
- requireSameNode: true
@ -1614,6 +1628,7 @@ pod:
manifests:
configmap_bin: true
configmap_etc: true
cron_job_cell_setup: true
daemonset_compute: true
deployment_api_metadata: true
deployment_api_osapi: true
@ -1639,7 +1654,6 @@ 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