From 110f428a6eb0f48278a793fc3e675dd36c57b1de Mon Sep 17 00:00:00 2001 From: Dae Seong Kim Date: Wed, 1 Nov 2017 10:58:44 +0900 Subject: [PATCH] Enable cell service This PS adds nova_cell0 database and init cell service. Change-Id: I29e33fb1a18f39586a7323dac82ddccbc445853f Implements: blueprint enable-cell-service --- nova/templates/bin/_cell-setup.sh.tpl | 21 ++++++++ nova/templates/configmap-bin.yaml | 2 + nova/templates/configmap-etc.yaml | 4 ++ nova/templates/job-cell-setup.yaml | 69 +++++++++++++++++++++++++++ nova/templates/job-db-init.yaml | 31 ++++++++++++ nova/values.yaml | 44 +++++++++++++++++ 6 files changed, 171 insertions(+) create mode 100644 nova/templates/bin/_cell-setup.sh.tpl create mode 100644 nova/templates/job-cell-setup.yaml diff --git a/nova/templates/bin/_cell-setup.sh.tpl b/nova/templates/bin/_cell-setup.sh.tpl new file mode 100644 index 0000000000..dd9a38b7e4 --- /dev/null +++ b/nova/templates/bin/_cell-setup.sh.tpl @@ -0,0 +1,21 @@ +#!/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 + +nova-manage cell_v2 simple_cell_setup diff --git a/nova/templates/configmap-bin.yaml b/nova/templates/configmap-bin.yaml index de8f8291af..dd94801005 100644 --- a/nova/templates/configmap-bin.yaml +++ b/nova/templates/configmap-bin.yaml @@ -73,4 +73,6 @@ data: {{ tuple "bin/_nova-vnc-proxy-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} ssh-start.sh: | {{ 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 }} {{- end }} diff --git a/nova/templates/configmap-etc.yaml b/nova/templates/configmap-etc.yaml index 4fee0608ab..7eff0653fc 100644 --- a/nova/templates/configmap-etc.yaml +++ b/nova/templates/configmap-etc.yaml @@ -60,6 +60,10 @@ limitations under the License. {{- tuple "oslo_db_api" "internal" "user" "mysql" . | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" | set .Values.conf.nova.api_database "connection" | quote | trunc 0 -}} {{- end -}} +{{- if empty .Values.conf.nova.cell0_database.connection -}} +{{- tuple "oslo_db_cell0" "internal" "user" "mysql" . | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" | set .Values.conf.nova.cell0_database "connection" | quote | trunc 0 -}} +{{- end -}} + {{- if empty .Values.conf.nova.DEFAULT.transport_url -}} {{- tuple "oslo_messaging" "internal" "user" "amqp" . | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" | set .Values.conf.nova.DEFAULT "transport_url" | quote | trunc 0 -}} {{- end -}} diff --git a/nova/templates/job-cell-setup.yaml b/nova/templates/job-cell-setup.yaml new file mode 100644 index 0000000000..9529a6f578 --- /dev/null +++ b/nova/templates/job-cell-setup.yaml @@ -0,0 +1,69 @@ +{{/* +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.cell_setup }} +--- +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: + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} + initContainers: +{{ tuple $envAll $dependencies "[]" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: + - name: nova-cell-setup + image: {{ .Values.images.tags.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/templates/job-db-init.yaml b/nova/templates/job-db-init.yaml index 8f884ba1d4..59f6a33d9a 100644 --- a/nova/templates/job-db-init.yaml +++ b/nova/templates/job-db-init.yaml @@ -92,6 +92,37 @@ spec: mountPath: /etc/nova/nova.conf subPath: nova.conf readOnly: true +{{- if .Values.manifests.job_cell_setup }} + - name: nova-db-init-cell0 + image: {{ .Values.images.tags.db_init }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.db_init | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + env: + - name: ROOT_DB_CONNECTION + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.oslo_db.admin }} + key: DB_CONNECTION + - name: OPENSTACK_CONFIG_FILE + value: /etc/nova/nova.conf + - name: OPENSTACK_CONFIG_DB_SECTION + value: cell0_database + - name: OPENSTACK_CONFIG_DB_KEY + value: connection + command: + - /tmp/db-init.py + volumeMounts: + - name: nova-bin + mountPath: /tmp/db-init.py + subPath: db-init.py + readOnly: true + - name: etcnova + mountPath: /etc/nova + - name: nova-etc + mountPath: /etc/nova/nova.conf + subPath: nova.conf + readOnly: true +{{- end }} volumes: - name: etcnova emptyDir: {} diff --git a/nova/values.yaml b/nova/values.yaml index 493a0e70f3..979b2508c4 100644 --- a/nova/values.yaml +++ b/nova/values.yaml @@ -69,6 +69,7 @@ images: placement: docker.io/kolla/ubuntu-source-nova-placement-api:3.0.3-beta.1 bootstrap: docker.io/kolla/ubuntu-source-heat-engine:3.0.3 dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1 + cell_setup: docker.io/kolla/ubuntu-source-nova-api:3.0.3 pull_policy: "IfNotPresent" bootstrap: @@ -266,6 +267,18 @@ dependencies: services: - service: oslo_db endpoint: internal + cell_setup: + jobs: + - nova-db-sync + services: + - service: oslo_messaging + endpoint: internal + - service: oslo_db + endpoint: internal + - service: identity + endpoint: internal + - service: compute + endpoint: internal console: # serial | spice | novnc | none @@ -985,6 +998,8 @@ conf: max_retries: -1 api_database: max_retries: -1 + cell0_database: + max_retries: -1 keystone_authtoken: auth_type: password auth_version: v3 @@ -1029,6 +1044,9 @@ secrets: oslo_db_api: admin: nova-db-api-admin user: nova-db-api-user + oslo_db_cell0: + admin: nova-db-api-admin + user: nova-db-api-user # typically overriden by environmental # values, but should include all endpoints @@ -1069,6 +1087,23 @@ endpoints: port: mysql: default: 3306 + oslo_db_cell0: + auth: + admin: + username: root + password: password + user: + username: nova + password: password + hosts: + default: mariadb + host_fqdn_override: + default: null + path: /nova_api_cell0 + scheme: mysql+pymysql + port: + mysql: + default: 3306 oslo_messaging: auth: admin: @@ -1431,6 +1466,14 @@ pod: limits: memory: "1024Mi" cpu: "2000m" + cell_setup: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "1024Mi" + cpu: "2000m" + manifests: configmap_bin: true @@ -1457,6 +1500,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