blob: 62db734bc3873d3e651db4ffcf0e5c38a5d6ff26 [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_backup_storage_init }}
16{{- $envAll := . }}
17
18{{- $serviceAccountName := "cinder-backup-storage-init" }}
19{{ tuple $envAll "backup_storage_init" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
20---
21apiVersion: rbac.authorization.k8s.io/v1
22kind: Role
23metadata:
24 name: {{ $serviceAccountName }}
25rules:
26 - apiGroups:
27 - ""
28 resources:
29 - secrets
30 verbs:
31 - get
32 - create
33 - update
34 - patch
35---
36apiVersion: rbac.authorization.k8s.io/v1
37kind: RoleBinding
38metadata:
39 name: {{ $serviceAccountName }}
40roleRef:
41 apiGroup: rbac.authorization.k8s.io
42 kind: Role
43 name: {{ $serviceAccountName }}
44subjects:
45 - kind: ServiceAccount
46 name: {{ $serviceAccountName }}
47 namespace: {{ $envAll.Release.Namespace }}
48---
49apiVersion: batch/v1
50kind: Job
51metadata:
52 name: cinder-backup-storage-init
53 labels:
54{{ tuple $envAll "cinder" "backup-storage-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
55 annotations:
Mohammed Naserfeec9952023-01-31 22:39:07 +000056{{- if .Values.helm3_hook }}
57 "helm.sh/hook": post-install,post-upgrade
58 "helm.sh/hook-delete-policy": before-hook-creation
59{{- end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050060 {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
61spec:
62 template:
63 metadata:
64 labels:
65{{ tuple $envAll "cinder" "storage-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
66 annotations:
67{{ dict "envAll" $envAll "podName" "cinder-backup-storage-init" "containerNames" (list "cinder-backup-storage-init" "init") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }}
68 spec:
69 serviceAccountName: {{ $serviceAccountName }}
70{{ dict "envAll" $envAll "application" "storage_init" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
71 restartPolicy: OnFailure
72{{ if $envAll.Values.pod.tolerations.cinder.enabled }}
73{{ tuple $envAll "cinder" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }}
74{{ end }}
75 nodeSelector:
76 {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
77 initContainers:
78{{ tuple $envAll "backup_storage_init" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
79 {{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
80 - name: ceph-keyring-placement
81{{ tuple $envAll "cinder_backup_storage_init" | include "helm-toolkit.snippets.image" | indent 10 }}
82{{ dict "envAll" $envAll "application" "storage_init" "container" "ceph_keyring_placement" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
83 command:
84 - /tmp/ceph-admin-keyring.sh
85 volumeMounts:
86 - name: pod-tmp
87 mountPath: /tmp
88 - name: etcceph
89 mountPath: /etc/ceph
90 {{- if not .Values.backup.external_ceph_rbd.enabled }}
91 - name: cinder-bin
92 mountPath: /tmp/ceph-admin-keyring.sh
93 subPath: ceph-admin-keyring.sh
94 readOnly: true
95 {{- else }}
96 - name: cinder-bin
97 mountPath: /tmp/ceph-admin-keyring.sh
98 subPath: external-ceph-rbd-admin-keyring.sh
99 readOnly: true
100 {{ end }}
101 {{- if empty .Values.conf.ceph.admin_keyring }}
102 - name: ceph-keyring
103 mountPath: /tmp/client-keyring
104 subPath: key
105 readOnly: true
106 {{ end }}
107 {{ end }}
108 containers:
109 - name: cinder-backup-storage-init
110{{ tuple $envAll "cinder_backup_storage_init" | include "helm-toolkit.snippets.image" | indent 10 }}
111{{ tuple $envAll $envAll.Values.pod.resources.jobs.backup_storage_init | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
112{{ dict "envAll" $envAll "application" "storage_init" "container" "cinder_backup_storage_init" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
113 env:
114 - name: NAMESPACE
115 valueFrom:
116 fieldRef:
117 fieldPath: metadata.namespace
118 - name: STORAGE_BACKEND
119 value: {{ .Values.conf.cinder.DEFAULT.backup_driver | quote }}
120 {{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
121 - name: RBD_POOL_NAME
122 value: {{ .Values.conf.cinder.DEFAULT.backup_ceph_pool | quote }}
123 - name: RBD_POOL_APP_NAME
124 value: {{ .Values.conf.ceph.pools.backup.app_name | quote }}
125 - name: RBD_POOL_USER
126 value: {{ .Values.conf.cinder.DEFAULT.backup_ceph_user | quote }}
127 - name: RBD_POOL_CRUSH_RULE
128 value: {{ .Values.conf.ceph.pools.backup.crush_rule | quote }}
129 - name: RBD_POOL_REPLICATION
130 value: {{ .Values.conf.ceph.pools.backup.replication | quote }}
131 - name: RBD_POOL_CHUNK_SIZE
132 value: {{ .Values.conf.ceph.pools.backup.chunk_size | quote }}
133 - name: RBD_POOL_SECRET
134 value: {{ .Values.secrets.rbd.backup | quote }}
135 {{ end }}
136 command:
137 - /tmp/backup-storage-init.sh
138 volumeMounts:
139 - name: pod-tmp
140 mountPath: /tmp
141 - name: cinder-bin
142 mountPath: /tmp/backup-storage-init.sh
143 subPath: backup-storage-init.sh
144 readOnly: true
145 {{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
146 - name: etcceph
147 mountPath: /etc/ceph
148 {{- if not .Values.backup.external_ceph_rbd.enabled }}
149 - name: ceph-etc
150 mountPath: /etc/ceph/ceph.conf
151 subPath: ceph.conf
152 readOnly: true
153 {{- else }}
154 - name: cinder-etc
155 mountPath: /etc/ceph/ceph.conf
156 subPath: external-backup-ceph.conf
157 readOnly: true
158 {{- end }}
159 {{- if empty .Values.conf.ceph.admin_keyring }}
160 - name: ceph-keyring
161 mountPath: /tmp/client-keyring
162 subPath: key
163 readOnly: true
164 {{- end }}
165 {{- end }}
166 volumes:
167 - name: pod-tmp
168 emptyDir: {}
169 - name: cinder-bin
170 configMap:
171 name: cinder-bin
172 defaultMode: 0555
173 {{- if (contains "cinder.backup.drivers.ceph" .Values.conf.cinder.DEFAULT.backup_driver) }}
174 - name: etcceph
175 emptyDir: {}
176 - name: ceph-etc
177 configMap:
178 name: {{ .Values.ceph_client.configmap }}
179 defaultMode: 0444
180 {{- if .Values.backup.external_ceph_rbd.enabled }}
181 - name: cinder-etc
182 secret:
183 secretName: cinder-etc
184 defaultMode: 0444
185 {{- end }}
186 {{- if empty .Values.conf.ceph.admin_keyring }}
187 - name: ceph-keyring
188 secret:
189 secretName: {{ .Values.ceph_client.user_secret_name }}
190 {{ end }}
191 {{ end }}
192{{- end }}