From 6571c9e2087782206813d93f3c178d0fd42a401a Mon Sep 17 00:00:00 2001 From: Vasyl Saienko Date: Wed, 4 Sep 2019 10:22:49 +0000 Subject: [PATCH] [Glance] add job-metadefs-load Glance provide default list of metadata definitions in /etc/glance/metadefs directory. The patch adds job that will load those defaults definitions. The job is enabled by default. Change-Id: Ib3ab20a9a7f73b568b029b06101cf4e5e2473716 --- glance/templates/bin/_metadefs-load.sh.tpl | 20 +++++ glance/templates/configmap-bin.yaml | 2 + glance/templates/job-metadefs-load.yaml | 85 ++++++++++++++++++++++ glance/values.yaml | 13 ++++ 4 files changed, 120 insertions(+) create mode 100644 glance/templates/bin/_metadefs-load.sh.tpl create mode 100644 glance/templates/job-metadefs-load.yaml diff --git a/glance/templates/bin/_metadefs-load.sh.tpl b/glance/templates/bin/_metadefs-load.sh.tpl new file mode 100644 index 0000000000..75d2b1904d --- /dev/null +++ b/glance/templates/bin/_metadefs-load.sh.tpl @@ -0,0 +1,20 @@ +#!/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. +*/}} + + +glance-manage --config-file /etc/glance/glance-api.conf db_load_metadefs /var/lib/openstack/etc/glance/metadefs diff --git a/glance/templates/configmap-bin.yaml b/glance/templates/configmap-bin.yaml index a3cf1eab50..847bdbda4f 100644 --- a/glance/templates/configmap-bin.yaml +++ b/glance/templates/configmap-bin.yaml @@ -35,6 +35,8 @@ data: {{ tuple $rallyTests | include "helm-toolkit.scripts.rally_test" | indent 4 }} storage-init.sh: | {{ tuple "bin/_storage-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + metadefs-load.sh: | +{{ tuple "bin/_metadefs-load.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} db-init.py: | {{- include "helm-toolkit.scripts.db_init" . | indent 4 }} db-sync.sh: | diff --git a/glance/templates/job-metadefs-load.yaml b/glance/templates/job-metadefs-load.yaml new file mode 100644 index 0000000000..d970431fab --- /dev/null +++ b/glance/templates/job-metadefs-load.yaml @@ -0,0 +1,85 @@ +{{/* +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_metadefs_load }} +{{- $envAll := . }} + +{{- $serviceAccountName := "glance-metadefs-load" }} +{{ tuple $envAll "metadefs_load" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: glance-metadefs-load + annotations: + {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} +spec: + template: + metadata: + labels: +{{ tuple $envAll "glance" "metadefs_load" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} + spec: + serviceAccountName: {{ $serviceAccountName }} +{{ dict "envAll" $envAll "application" "glance" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} + initContainers: +{{ tuple $envAll "metadefs_load" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: + - name: glance-metadefs-load +{{ tuple $envAll "glance_metadefs_load" | include "helm-toolkit.snippets.image" | indent 10 }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.metadefs_load | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + command: + - /tmp/metadefs-load.sh + volumeMounts: + - name: pod-tmp + mountPath: /tmp + - name: glance-bin + mountPath: /tmp/metadefs-load.sh + subPath: metadefs-load.sh + readOnly: true + - name: etcglance + mountPath: /etc/glance + - name: glance-etc + mountPath: /etc/glance/glance-api.conf + subPath: glance-api.conf + readOnly: true + {{- if .Values.conf.glance.DEFAULT.log_config_append }} + - name: glance-etc + mountPath: {{ .Values.conf.glance.DEFAULT.log_config_append }} + subPath: {{ base .Values.conf.glance.DEFAULT.log_config_append }} + readOnly: true + {{- end }} + volumes: + - name: pod-tmp + emptyDir: {} + - name: glance-bin + configMap: + name: glance-bin + defaultMode: 0555 + - name: etcglance + emptyDir: {} + - name: glance-etc + secret: + secretName: glance-etc + defaultMode: 0444 +{{- end }} diff --git a/glance/values.yaml b/glance/values.yaml index 17bdf4dfe2..193a56a041 100644 --- a/glance/values.yaml +++ b/glance/values.yaml @@ -40,6 +40,7 @@ images: tags: test: docker.io/xrally/xrally-openstack:1.3.0 glance_storage_init: docker.io/port/ceph-config-helper:v1.10.3 + glance_metadefs_load: docker.io/openstackhelm/glance:ocata-ubuntu_xenial db_init: docker.io/openstackhelm/heat:ocata-ubuntu_xenial glance_db_sync: docker.io/openstackhelm/glance:ocata-ubuntu_xenial db_drop: docker.io/openstackhelm/heat:ocata-ubuntu_xenial @@ -563,6 +564,10 @@ dependencies: jobs: - glance-ks-user services: null + metadefs_load: + jobs: + - glance-db-sync + services: null tests: services: - endpoint: internal @@ -927,6 +932,13 @@ pod: limits: memory: "1024Mi" cpu: "2000m" + metadefs_load: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "1024Mi" + cpu: "2000m" db_sync: requests: memory: "128Mi" @@ -1015,6 +1027,7 @@ manifests: job_ks_service: true job_ks_user: true job_storage_init: true + job_metadefs_load: true job_rabbit_init: true pdb_api: true pdb_registry: false