From 897edb32023b28ad9cb4bc880ede0b43a50fd13a Mon Sep 17 00:00:00 2001 From: portdirect Date: Tue, 13 Feb 2018 11:53:17 -0500 Subject: [PATCH] DB-Init-Jobs: consolidate to helm-toolkit This PS consolidates the DB-Init Job to helm-toolkit. Change-Id: Ib92743d678de09a6fb4457e5415a098013952410 --- barbican/templates/job-db-init.yaml | 67 +-------- ceilometer/templates/job-db-init.yaml | 62 +-------- cinder/templates/job-db-init.yaml | 65 +-------- congress/templates/job-db-init.yaml | 65 +-------- glance/templates/job-db-init.yaml | 67 +-------- gnocchi/templates/job-db-init.yaml | 65 +-------- heat/templates/job-db-init.yaml | 65 +-------- .../manifests/_job-db-init-mysql.yaml.tpl | 120 ++++++++++++++++ horizon/templates/job-db-init.yaml | 58 +------- horizon/values.yaml | 3 + ironic/templates/job-db-init.yaml | 65 +-------- ironic/values.yaml | 3 + keystone/templates/job-db-init.yaml | 70 +--------- keystone/values.yaml | 3 + magnum/templates/job-db-init.yaml | 65 +-------- mistral/templates/job-db-init.yaml | 65 +-------- neutron/templates/job-db-init.yaml | 65 +-------- nova/templates/job-db-init.yaml | 130 +----------------- rally/templates/job-db-init.yaml | 65 +-------- senlin/templates/job-db-init.yaml | 65 +-------- 20 files changed, 171 insertions(+), 1062 deletions(-) create mode 100644 helm-toolkit/templates/manifests/_job-db-init-mysql.yaml.tpl diff --git a/barbican/templates/job-db-init.yaml b/barbican/templates/job-db-init.yaml index 9f47f53b62..c2ba7c7bff 100644 --- a/barbican/templates/job-db-init.yaml +++ b/barbican/templates/job-db-init.yaml @@ -15,67 +15,8 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "barbican-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: barbican-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "barbican" "db-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} - spec: - serviceAccountName: {{ $serviceAccountName }} - restartPolicy: OnFailure - nodeSelector: - {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} - initContainers: -{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} - containers: - - name: barbican-db-init - 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/barbican/barbican.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: DEFAULT - - name: OPENSTACK_CONFIG_DB_KEY - value: sql_connection - command: - - /tmp/db-init.py - volumeMounts: - - name: barbican-etc - mountPath: /etc/barbican - - name: barbican-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: barbican-conf - mountPath: /etc/barbican/barbican.conf - subPath: barbican.conf - readOnly: true - volumes: - - name: barbican-etc - emptyDir: {} - - name: barbican-conf - configMap: - name: barbican-etc - defaultMode: 0444 - - name: barbican-bin - configMap: - name: barbican-bin - defaultMode: 0555 +{{- $serviceName := "barbican" -}} +{{- $dbToInit := dict "adminSecret" .Values.secrets.oslo_db.admin "configFile" (printf "/etc/%s/%s.conf" $serviceName $serviceName ) "configDbSection" "DEFAULT" "configDbKey" "sql_connection" -}} +{{- $dbInitJob := dict "envAll" . "serviceName" $serviceName "dbToInit" $dbToInit -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/ceilometer/templates/job-db-init.yaml b/ceilometer/templates/job-db-init.yaml index 5d20127d94..2a3ebf47d7 100644 --- a/ceilometer/templates/job-db-init.yaml +++ b/ceilometer/templates/job-db-init.yaml @@ -15,64 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "ceilometer-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: ceilometer-db-init -spec: - template: - 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: ceilometer-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/ceilometer/ceilometer.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: ceilometer-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcceilometer - mountPath: /etc/ceilometer - - name: ceilometer-etc - mountPath: /etc/ceilometer/ceilometer.conf - subPath: ceilometer.conf - readOnly: true - volumes: - - name: etcceilometer - emptyDir: {} - - name: ceilometer-etc - configMap: - name: ceilometer-etc - defaultMode: 0444 - - name: ceilometer-bin - configMap: - name: ceilometer-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "ceilometer" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/cinder/templates/job-db-init.yaml b/cinder/templates/job-db-init.yaml index 5a38ff81c9..f79bd8d1e1 100644 --- a/cinder/templates/job-db-init.yaml +++ b/cinder/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "cinder-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: cinder-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "cinder" "db-init" | 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: cinder-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/cinder/cinder.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: cinder-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etccinder - mountPath: /etc/cinder - - name: cinder-etc - mountPath: /etc/cinder/cinder.conf - subPath: cinder.conf - readOnly: true - volumes: - - name: etccinder - emptyDir: {} - - name: cinder-etc - configMap: - name: cinder-etc - defaultMode: 0444 - - name: cinder-bin - configMap: - name: cinder-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "cinder" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/congress/templates/job-db-init.yaml b/congress/templates/job-db-init.yaml index 66b782ac98..740a39ba8b 100644 --- a/congress/templates/job-db-init.yaml +++ b/congress/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "congress-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: congress-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "congress" "db-init" | 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: congress-db-init - 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/congress/congress.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: congress-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etccongress - mountPath: /etc/congress - - name: congress-etc - mountPath: /etc/congress/congress.conf - subPath: congress.conf - readOnly: true - volumes: - - name: etccongress - emptyDir: {} - - name: congress-etc - configMap: - name: congress-etc - defaultMode: 0444 - - name: congress-bin - configMap: - name: congress-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "congress" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/glance/templates/job-db-init.yaml b/glance/templates/job-db-init.yaml index c188654b23..282f626a6b 100644 --- a/glance/templates/job-db-init.yaml +++ b/glance/templates/job-db-init.yaml @@ -15,67 +15,8 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "glance-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: glance-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "glance" "db-init" | 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: glance-db-init - 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/glance/glance-api.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: glance-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcglance - mountPath: /etc/glance - - name: glance-etc - mountPath: /etc/glance/glance-api.conf - subPath: glance-api.conf - readOnly: true - volumes: - - name: etcglance - emptyDir: {} - - name: glance-etc - configMap: - name: glance-etc - defaultMode: 0444 - - name: glance-bin - configMap: - name: glance-bin - defaultMode: 0555 +{{- $serviceName := "glance" -}} +{{- $dbToInit := dict "adminSecret" .Values.secrets.oslo_db.admin "configFile" (printf "/etc/%s/%s.conf" $serviceName "glance-api" ) "configDbSection" "database" "configDbKey" "connection" -}} +{{- $dbInitJob := dict "envAll" . "serviceName" $serviceName "dbToInit" $dbToInit -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/gnocchi/templates/job-db-init.yaml b/gnocchi/templates/job-db-init.yaml index 719e7006f1..f6da03ea0b 100644 --- a/gnocchi/templates/job-db-init.yaml +++ b/gnocchi/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "gnocchi-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: gnocchi-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "gnocchi" "db-init" | 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: keystone-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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_API - - name: OPENSTACK_CONFIG_FILE - value: /etc/gnocchi/gnocchi.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: gnocchi-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: pod-etc-gnocchi - mountPath: /etc/gnocchi - - name: gnocchi-etc - mountPath: /etc/gnocchi/gnocchi.conf - subPath: gnocchi.conf - readOnly: true - volumes: - - name: gnocchi-bin - configMap: - name: gnocchi-bin - defaultMode: 0555 - - name: pod-etc-gnocchi - emptyDir: {} - - name: gnocchi-etc - configMap: - name: gnocchi-etc - defaultMode: 0444 +{{- $dbInitJob := dict "envAll" . "serviceName" "gnocchi" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/heat/templates/job-db-init.yaml b/heat/templates/job-db-init.yaml index 663a9b0143..292ff04b4f 100644 --- a/heat/templates/job-db-init.yaml +++ b/heat/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "heat-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: heat-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "heat" "db-init" | 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: heat-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/heat/heat.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: heat-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcheat - mountPath: /etc/heat - - name: heat-etc - mountPath: /etc/heat/heat.conf - subPath: heat.conf - readOnly: true - volumes: - - name: etcheat - emptyDir: {} - - name: heat-etc - configMap: - name: heat-etc - defaultMode: 0444 - - name: heat-bin - configMap: - name: heat-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "heat" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/helm-toolkit/templates/manifests/_job-db-init-mysql.yaml.tpl b/helm-toolkit/templates/manifests/_job-db-init-mysql.yaml.tpl new file mode 100644 index 0000000000..f17c06dd5d --- /dev/null +++ b/helm-toolkit/templates/manifests/_job-db-init-mysql.yaml.tpl @@ -0,0 +1,120 @@ +{{/* +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. +*/}} + +# This function creates a manifest for db creation and user management. +# It can be used in charts dict created similar to the following: +# {- $dbToInitJob := dict "envAll" . "serviceName" "senlin" -} +# { $dbToInitJob | include "helm-toolkit.manifests.job_db_init_mysql" } +# +# If the service does not use olso then the db can be managed with: +# {- $dbToInit := dict "inputType" "secret" "adminSecret" .Values.secrets.oslo_db.admin "userSecret" .Values.secrets.oslo_db.horizon -} +# {- $dbToInitJob := dict "envAll" . "serviceName" "horizon" "dbToInit" $dbToInit -} +# { $dbToInitJob | include "helm-toolkit.manifests.job_db_init_mysql" } + +{{- define "helm-toolkit.manifests.job_db_init_mysql" -}} +{{- $envAll := index . "envAll" -}} +{{- $serviceName := index . "serviceName" -}} +{{- $nodeSelector := index . "nodeSelector" | default ( dict $envAll.Values.labels.job.node_selector_key $envAll.Values.labels.job.node_selector_value ) -}} +{{- $dependencies := index . "dependencies" | default $envAll.Values.dependencies.db_init -}} +{{- $configMapBin := index . "configMapBin" | default (printf "%s-%s" $serviceName "bin" ) -}} +{{- $configMapEtc := index . "configMapEtc" | default (printf "%s-%s" $serviceName "etc" ) -}} +{{- $dbToInit := index . "dbToInit" | default ( dict "adminSecret" $envAll.Values.secrets.oslo_db.admin "configFile" (printf "/etc/%s/%s.conf" $serviceName $serviceName ) "configDbSection" "database" "configDbKey" "connection" ) -}} +{{- $dbsToInit := default (list $dbToInit) (index . "dbsToInit") }} + +{{- $serviceNamePretty := $serviceName | replace "_" "-" -}} + +{{- $serviceAccountName := printf "%s-%s" $serviceNamePretty "db-init" }} +{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ printf "%s-%s" $serviceNamePretty "db-init" | quote }} +spec: + template: + metadata: + labels: +{{ tuple $envAll $serviceName "db-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} + spec: + serviceAccountName: {{ $serviceAccountName }} + restartPolicy: OnFailure + nodeSelector: +{{ toYaml $nodeSelector | indent 8 }} + initContainers: +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: +{{- range $key1, $dbToInit := $dbsToInit }} +{{ $dbToInitType := default "oslo" $dbToInit.inputType }} + - name: {{ printf "%s-%s-%d" $serviceNamePretty "db-init" $key1 | quote }} + image: {{ $envAll.Values.images.tags.db_init | quote }} + imagePullPolicy: {{ $envAll.Values.images.pull_policy | quote }} +{{ 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: {{ $dbToInit.adminSecret | quote }} + key: DB_CONNECTION +{{- if eq $dbToInitType "oslo" }} + - name: OPENSTACK_CONFIG_FILE + value: {{ $dbToInit.configFile | quote }} + - name: OPENSTACK_CONFIG_DB_SECTION + value: {{ $dbToInit.configDbSection | quote }} + - name: OPENSTACK_CONFIG_DB_KEY + value: {{ $dbToInit.configDbKey | quote }} +{{- end }} +{{- if eq $dbToInitType "secret" }} + - name: DB_CONNECTION + valueFrom: + secretKeyRef: + name: {{ $dbToInit.userSecret | quote }} + key: DB_CONNECTION +{{- end }} + command: + - /tmp/db-init.py + volumeMounts: + - name: db-init-sh + mountPath: /tmp/db-init.py + subPath: db-init.py + readOnly: true +{{- if eq $dbToInitType "oslo" }} + - name: etc-service + mountPath: {{ dir $dbToInit.configFile | quote }} + - name: db-init-conf + mountPath: {{ $dbToInit.configFile | quote }} + subPath: {{ base $dbToInit.configFile | quote }} + readOnly: true +{{- end }} +{{- end }} + volumes: + - name: db-init-sh + configMap: + name: {{ $configMapBin | quote }} + defaultMode: 0555 +{{- $local := dict "configMapBinFirst" true -}} +{{- range $key1, $dbToInit := $dbsToInit }} +{{- $dbToInitType := default "oslo" $dbToInit.inputType }} +{{- if and (eq $dbToInitType "oslo") $local.configMapBinFirst }} +{{- $_ := set $local "configMapBinFirst" false }} + - name: etc-service + emptyDir: {} + - name: db-init-conf + configMap: + name: {{ $configMapEtc | quote }} + defaultMode: 0444 +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/horizon/templates/job-db-init.yaml b/horizon/templates/job-db-init.yaml index 63e92e6102..d6d3d8a17e 100644 --- a/horizon/templates/job-db-init.yaml +++ b/horizon/templates/job-db-init.yaml @@ -15,59 +15,7 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $mounts_horizon_db_init := .Values.pod.mounts.horizon_db_init.horizon_db_init }} -{{- $mounts_horizon_db_init_init := .Values.pod.mounts.horizon_db_init.init_container }} - -{{- $serviceAccountName := "horizon-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: horizon-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "horizon" "db-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} - spec: - serviceAccountName: {{ $serviceAccountName }} - restartPolicy: OnFailure - nodeSelector: - {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} - initContainers: -{{ tuple $envAll $dependencies $mounts_horizon_db_init_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} - containers: - - name: horizon-db-init - 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: DB_CONNECTION - valueFrom: - secretKeyRef: - name: {{ .Values.secrets.oslo_db.horizon }} - key: DB_CONNECTION - command: - - /tmp/db-init.py - volumeMounts: - - name: horizon-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true -{{ if $mounts_horizon_db_init.volumeMounts }}{{ toYaml $mounts_horizon_db_init.volumeMounts | indent 10 }}{{ end }} - volumes: - - name: horizon-bin - configMap: - name: horizon-bin - defaultMode: 0555 -{{ if $mounts_horizon_db_init.volumes }}{{ toYaml $mounts_horizon_db_init.volumes | indent 6 }}{{ end }} +{{- $dbToInit := dict "inputType" "secret" "adminSecret" .Values.secrets.oslo_db.admin "userSecret" .Values.secrets.oslo_db.horizon -}} +{{- $dbInitJob := dict "envAll" . "serviceName" "horizon" "dbToInit" $dbToInit -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/horizon/values.yaml b/horizon/values.yaml index 44723b3613..1943635e92 100644 --- a/horizon/values.yaml +++ b/horizon/values.yaml @@ -31,6 +31,9 @@ release_group: null labels: node_selector_key: openstack-control-plane node_selector_value: enabled + job: + node_selector_key: openstack-control-plane + node_selector_value: enabled network: port: 80 diff --git a/ironic/templates/job-db-init.yaml b/ironic/templates/job-db-init.yaml index d98ef79c13..43764729b1 100644 --- a/ironic/templates/job-db-init.yaml +++ b/ironic/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "ironic-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: ironic-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "ironic" "db-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} - spec: - serviceAccountName: {{ $serviceAccountName }} - restartPolicy: OnFailure - nodeSelector: - {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} - initContainers: -{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} - containers: - - name: ironic-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/ironic/ironic.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: ironic-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcironic - mountPath: /etc/ironic - - name: ironic-etc - mountPath: /etc/ironic/ironic.conf - subPath: ironic.conf - readOnly: true - volumes: - - name: etcironic - emptyDir: {} - - name: ironic-etc - configMap: - name: ironic-etc - defaultMode: 0444 - - name: ironic-bin - configMap: - name: ironic-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "ironic" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/ironic/values.yaml b/ironic/values.yaml index 960c14d850..ccfd595951 100644 --- a/ironic/values.yaml +++ b/ironic/values.yaml @@ -20,6 +20,9 @@ labels: node_selector_key: openstack-control-plane node_selector_value: enabled + job: + node_selector_key: openstack-control-plane + node_selector_value: enabled images: tags: diff --git a/keystone/templates/job-db-init.yaml b/keystone/templates/job-db-init.yaml index ef00635549..8451fa2773 100644 --- a/keystone/templates/job-db-init.yaml +++ b/keystone/templates/job-db-init.yaml @@ -15,72 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $mounts_keystone_db_init := .Values.pod.mounts.keystone_db_init.keystone_db_init }} -{{- $mounts_keystone_db_init_init := .Values.pod.mounts.keystone_db_init.init_container }} - -{{- $serviceAccountName := "keystone-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: keystone-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "keystone" "db-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} - spec: - serviceAccountName: {{ $serviceAccountName }} - restartPolicy: OnFailure - nodeSelector: - {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} - initContainers: -{{ tuple $envAll $dependencies $mounts_keystone_db_init_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} - containers: - - name: keystone-db-init - 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/keystone/keystone.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: etckeystone - mountPath: /etc/keystone - - name: keystone-etc - mountPath: /etc/keystone/keystone.conf - subPath: keystone.conf - readOnly: true - - name: keystone-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true -{{ if $mounts_keystone_db_init.volumeMounts }}{{ toYaml $mounts_keystone_db_init.volumeMounts | indent 10 }}{{ end }} - volumes: - - name: etckeystone - emptyDir: {} - - name: keystone-etc - configMap: - name: keystone-etc - defaultMode: 0444 - - name: keystone-bin - configMap: - name: keystone-bin - defaultMode: 0555 -{{ if $mounts_keystone_db_init.volumes }}{{ toYaml $mounts_keystone_db_init.volumes | indent 6 }}{{ end }} +{{- $dbInitJob := dict "envAll" . "serviceName" "keystone" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/keystone/values.yaml b/keystone/values.yaml index 107a16807e..98ef500736 100644 --- a/keystone/values.yaml +++ b/keystone/values.yaml @@ -20,6 +20,9 @@ labels: node_selector_key: openstack-control-plane node_selector_value: enabled + job: + node_selector_key: openstack-control-plane + node_selector_value: enabled release_group: null diff --git a/magnum/templates/job-db-init.yaml b/magnum/templates/job-db-init.yaml index 75a4b54bba..6c150e8e96 100644 --- a/magnum/templates/job-db-init.yaml +++ b/magnum/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "magnum-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: magnum-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "magnum" "db-init" | 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: magnum-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/magnum/magnum.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: magnum-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcmagnum - mountPath: /etc/magnum - - name: magnum-etc - mountPath: /etc/magnum/magnum.conf - subPath: magnum.conf - readOnly: true - volumes: - - name: etcmagnum - emptyDir: {} - - name: magnum-etc - configMap: - name: magnum-etc - defaultMode: 0444 - - name: magnum-bin - configMap: - name: magnum-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "magnum" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/mistral/templates/job-db-init.yaml b/mistral/templates/job-db-init.yaml index 1effc448ce..817faf1e79 100644 --- a/mistral/templates/job-db-init.yaml +++ b/mistral/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "mistral-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: mistral-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "mistral" "db-init" | 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: mistral-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/mistral/mistral.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: mistral-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: pod-etc-mistral - mountPath: /etc/mistral - - name: mistral-etc - mountPath: /etc/mistral/mistral.conf - subPath: mistral.conf - readOnly: true - volumes: - - name: mistral-bin - configMap: - name: mistral-bin - defaultMode: 0555 - - name: pod-etc-mistral - emptyDir: {} - - name: mistral-etc - configMap: - name: mistral-etc - defaultMode: 0444 +{{- $dbInitJob := dict "envAll" . "serviceName" "mistral" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/neutron/templates/job-db-init.yaml b/neutron/templates/job-db-init.yaml index 59a53bfb34..7b302a3cf8 100644 --- a/neutron/templates/job-db-init.yaml +++ b/neutron/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "neutron-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: neutron-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "neutron" "db-init" | 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: neutron-db-init - 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/neutron/neutron.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: neutron-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcneutron - mountPath: /etc/neutron - - name: neutron-etc - mountPath: /etc/neutron/neutron.conf - subPath: neutron.conf - readOnly: true - volumes: - - name: etcneutron - emptyDir: {} - - name: neutron-etc - configMap: - name: neutron-etc - defaultMode: 0444 - - name: neutron-bin - configMap: - name: neutron-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "neutron" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/nova/templates/job-db-init.yaml b/nova/templates/job-db-init.yaml index b4dc730b19..0fd7783da5 100644 --- a/nova/templates/job-db-init.yaml +++ b/nova/templates/job-db-init.yaml @@ -15,127 +15,11 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "nova-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: nova-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "nova" "db-init" | 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-db-init - 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: 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 - - name: nova-db-init-api - 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: api_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 -{{- 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: {} - - name: nova-etc - configMap: - name: nova-etc - defaultMode: 0444 - - name: nova-bin - configMap: - name: nova-bin - defaultMode: 0555 +{{- $serviceName := "nova" -}} +{{- $dbSvc := dict "adminSecret" .Values.secrets.oslo_db.admin "configFile" (printf "/etc/%s/%s.conf" $serviceName $serviceName ) "configDbSection" "database" "configDbKey" "connection" -}} +{{- $dbApi := dict "adminSecret" .Values.secrets.oslo_db.admin "configFile" (printf "/etc/%s/%s.conf" $serviceName $serviceName ) "configDbSection" "api_database" "configDbKey" "connection" -}} +{{- $dbCell := dict "adminSecret" .Values.secrets.oslo_db.admin "configFile" (printf "/etc/%s/%s.conf" $serviceName $serviceName ) "configDbSection" "cell0_database" "configDbKey" "connection" -}} +{{- $dbsToInit := list $dbSvc $dbApi $dbCell }} +{{- $dbInitJob := dict "envAll" . "serviceName" $serviceName "dbsToInit" $dbsToInit -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/rally/templates/job-db-init.yaml b/rally/templates/job-db-init.yaml index a63e9b6af8..6c7414e480 100644 --- a/rally/templates/job-db-init.yaml +++ b/rally/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "rally-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: rally-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "rally" "db-init" | 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: rally-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/rally/rally.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: rally-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcrally - mountPath: /etc/rally - - name: rally-etc - mountPath: /etc/rally/rally.conf - subPath: rally.conf - readOnly: true - volumes: - - name: etcrally - emptyDir: {} - - name: rally-etc - configMap: - name: rally-etc - defaultMode: 0444 - - name: rally-bin - configMap: - name: rally-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "rally" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }} diff --git a/senlin/templates/job-db-init.yaml b/senlin/templates/job-db-init.yaml index 3a55c5c09d..783cdac530 100644 --- a/senlin/templates/job-db-init.yaml +++ b/senlin/templates/job-db-init.yaml @@ -15,67 +15,6 @@ limitations under the License. */}} {{- if .Values.manifests.job_db_init }} -{{- $envAll := . }} -{{- $dependencies := .Values.dependencies.db_init }} - -{{- $serviceAccountName := "senlin-db-init" }} -{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: senlin-db-init -spec: - template: - metadata: - labels: -{{ tuple $envAll "senlin" "db-init" | 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: senlin-db-init - image: {{ .Values.images.tags.db_init | quote }} - imagePullPolicy: {{ .Values.images.pull_policy | quote }} -{{ 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/senlin/senlin.conf - - name: OPENSTACK_CONFIG_DB_SECTION - value: database - - name: OPENSTACK_CONFIG_DB_KEY - value: connection - command: - - /tmp/db-init.py - volumeMounts: - - name: senlin-bin - mountPath: /tmp/db-init.py - subPath: db-init.py - readOnly: true - - name: etcsenlin - mountPath: /etc/senlin - - name: senlin-etc - mountPath: /etc/senlin/senlin.conf - subPath: senlin.conf - readOnly: true - volumes: - - name: etcsenlin - emptyDir: {} - - name: senlin-etc - configMap: - name: senlin-etc - defaultMode: 0444 - - name: senlin-bin - configMap: - name: senlin-bin - defaultMode: 0555 +{{- $dbInitJob := dict "envAll" . "serviceName" "senlin" -}} +{{ $dbInitJob | include "helm-toolkit.manifests.job_db_init_mysql" }} {{- end }}