blob: c2229cdd082fbae7d465ad221b0534443e34dab8 [file] [log] [blame]
Mohammed Naserf3f59a72023-01-15 21:02:04 -05001{{/*
2Licensed under the Apache License, Version 2.0 (the "License");
3you may not use this file except in compliance with the License.
4You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8Unless required by applicable law or agreed to in writing, software
9distributed under the License is distributed on an "AS IS" BASIS,
10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11See the License for the specific language governing permissions and
12limitations under the License.
13*/}}
14
15{{- if .Values.manifests.job_db_sync }}
16{{- $envAll := . }}
17
18{{- $mounts_horizon_db_sync := .Values.pod.mounts.horizon_db_sync.horizon_db_sync }}
19{{- $mounts_horizon_db_sync_init := .Values.pod.mounts.horizon_db_sync.init_container }}
20
21{{- $serviceAccountName := "horizon-db-sync" }}
22{{ tuple $envAll "db_sync" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
23---
24apiVersion: batch/v1
25kind: Job
26metadata:
27 name: horizon-db-sync
28 labels:
29{{ tuple $envAll "horizon" "db-sync" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
30 annotations:
31{{- if .Values.helm3_hook }}
32 helm.sh/hook: post-install,post-upgrade
33 helm.sh/hook-weight: "-4"
34{{- end }}
35 {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
36spec:
37 template:
38 metadata:
39 labels:
40{{ tuple $envAll "horizon" "db-sync" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
41 annotations:
42{{ dict "envAll" $envAll "podName" "horizon-db-sync" "containerNames" (list "horizon-db-sync" "init" ) | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }}
43 spec:
44 serviceAccountName: {{ $serviceAccountName }}
45{{ dict "envAll" $envAll "application" "db_sync" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
46 restartPolicy: OnFailure
47 nodeSelector:
48 {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
49{{ if $envAll.Values.pod.tolerations.horizon.enabled }}
50{{ tuple $envAll "horizon" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }}
51{{ end }}
52 initContainers:
53{{ tuple $envAll "db_sync" $mounts_horizon_db_sync_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
54 containers:
55 - name: horizon-db-sync
56{{ tuple $envAll "horizon_db_sync" | include "helm-toolkit.snippets.image" | indent 10 }}
57{{ tuple $envAll $envAll.Values.pod.resources.jobs.db_sync | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
58{{ dict "envAll" $envAll "application" "db_sync" "container" "horizon_db_sync" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
59 command:
60 - /tmp/db-sync.sh
61 volumeMounts:
62 - name: horizon-etc
63 mountPath: /etc/openstack-dashboard/local_settings
64 subPath: local_settings
65 readOnly: true
66 - name: horizon-bin
67 mountPath: /tmp/db-sync.sh
68 subPath: db-sync.sh
69 readOnly: true
70 - name: horizon-bin
71 mountPath: /tmp/manage.py
72 subPath: manage.py
73 readOnly: true
74{{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_db.auth.admin.secret.tls.internal "path" "/etc/mysql/certs" | include "helm-toolkit.snippets.tls_volume_mount" | indent 10 }}
75{{ if $mounts_horizon_db_sync.volumeMounts }}{{ toYaml $mounts_horizon_db_sync.volumeMounts | indent 10 }}{{ end }}
76 volumes:
77 - name: horizon-etc
78 secret:
79 secretName: horizon-etc
80 defaultMode: 0444
81 - name: horizon-bin
82 configMap:
83 name: horizon-bin
84 defaultMode: 0555
85{{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_db.auth.admin.secret.tls.internal | include "helm-toolkit.snippets.tls_volume" | indent 6 }}
86{{ if $mounts_horizon_db_sync.volumes }}{{ toYaml $mounts_horizon_db_sync.volumes | indent 6 }}{{ end }}
87{{- end }}