blob: fb0d626aede929d4600a52e2e102897e08c1ddbb [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.deployment_volume }}
16{{- $envAll := . }}
17
18{{- $internal_ceph_backend := .Values.ceph_client.internal_ceph_backend }}
19
20{{- $mounts_cinder_volume := .Values.pod.mounts.cinder_volume.cinder_volume }}
21{{- $mounts_cinder_volume_init := .Values.pod.mounts.cinder_volume.init_container }}
22
23{{- $serviceAccountName := "cinder-volume" }}
24{{ tuple $envAll "volume" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
25---
26apiVersion: apps/v1
27kind: Deployment
28metadata:
29 name: cinder-volume
30 annotations:
31 {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
32 labels:
33{{ tuple $envAll "cinder" "volume" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
34spec:
35 replicas: {{ .Values.pod.replicas.volume }}
36 selector:
37 matchLabels:
38{{ tuple $envAll "cinder" "volume" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
39{{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }}
40 template:
41 metadata:
42 labels:
43{{ tuple $envAll "cinder" "volume" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
44 annotations:
45{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }}
46 configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }}
47 configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }}
Rico Lin73060242024-08-22 00:27:56 +080048{{ tuple "cinder_volume" . | include "helm-toolkit.snippets.custom_pod_annotations" | indent 8 }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050049{{ dict "envAll" $envAll "podName" "cinder-volume" "containerNames" (list "cinder-volume" "ceph-coordination-volume-perms" "init-cinder-conf" "init" ) | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }}
50 spec:
Mohammed Naser26eb9e02025-02-05 16:40:34 -050051{{ with .Values.pod.priorityClassName.cinder_volume }}
52 priorityClassName: {{ . }}
53{{ end }}
54{{ with .Values.pod.runtimeClassName.cinder_volume }}
55 runtimeClassName: {{ . }}
56{{ end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050057 serviceAccountName: {{ $serviceAccountName }}
58{{ dict "envAll" $envAll "application" "cinder_volume" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
59 affinity:
60{{ tuple $envAll "cinder" "volume" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
61{{ if $envAll.Values.pod.tolerations.cinder.enabled }}
62{{ tuple $envAll "cinder" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }}
63{{ end }}
64 nodeSelector:
65 {{ .Values.labels.volume.node_selector_key }}: {{ .Values.labels.volume.node_selector_value }}
66{{- if .Values.pod.useHostNetwork.volume }}
67 hostNetwork: true
68 dnsPolicy: ClusterFirstWithHostNet
69{{- end }}
70{{- if .Values.conf.enable_iscsi }}
71 hostIPC: true
72{{- end }}
73 initContainers:
74{{ tuple $envAll "volume" $mounts_cinder_volume_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
75 {{- range $name := rest (splitList "," (include "cinder.utils.ceph_backend_list" $envAll)) }}
76 {{- $backend := index $envAll.Values.conf.backends $name }}
77 {{- if eq $internal_ceph_backend $name }}
Mohammed Naser6a7426e2023-02-23 18:30:25 +000078 - name: ceph-keyring-placement-{{ $name | lower }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050079{{ tuple $envAll "cinder_volume" | include "helm-toolkit.snippets.image" | indent 10 }}
80{{ dict "envAll" $envAll "application" "cinder_volume" "container" "ceph_keyring_placement" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
81 command:
82 - /tmp/ceph-keyring.sh
83 env:
84 - name: RBD_USER
85 value: {{ $backend.rbd_user | quote }}
86{{- if and $envAll.Values.ceph_client.enable_external_ceph_backend $envAll.Values.ceph_client.external_ceph.rbd_user }}
87 - name: EXTERNAL_RBD_USER
88 value: {{ $envAll.Values.ceph_client.external_ceph.rbd_user | quote }}
89{{- end }}
90 volumeMounts:
91 - name: pod-tmp
92 mountPath: /tmp
93 - name: etcceph
94 mountPath: /etc/ceph
95 - name: cinder-bin
96 mountPath: /tmp/ceph-keyring.sh
97 subPath: ceph-keyring.sh
98 readOnly: true
99 - name: ceph-keyring
100 mountPath: /tmp/client-keyring
101 subPath: key
102 readOnly: true
103 {{- if and $envAll.Values.ceph_client.enable_external_ceph_backend $envAll.Values.ceph_client.external_ceph.rbd_user }}
104 - name: external-ceph-keyring
105 mountPath: /tmp/external-ceph-client-keyring
106 subPath: key
107 readOnly: true
108 {{- end }}
109 {{- end }}
110 {{- end }}
111 {{- if eq ( split "://" .Values.conf.cinder.coordination.backend_url )._0 "file" }}
112 - name: ceph-coordination-volume-perms
113{{ tuple $envAll "cinder_volume" | include "helm-toolkit.snippets.image" | indent 10 }}
114{{ dict "envAll" $envAll "application" "cinder_volume" "container" "ceph_coordination_volume_perms" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
115 command:
116 - chown
117 - -R
118 - "cinder:"
119 - {{ ( split "://" .Values.conf.cinder.coordination.backend_url )._1 }}
120 volumeMounts:
121 - name: pod-tmp
122 mountPath: /tmp
123 - name: cinder-coordination
124 mountPath: {{ ( split "://" .Values.conf.cinder.coordination.backend_url )._1 }}
125 {{ end }}
126 - name: init-cinder-conf
127{{ dict "envAll" $envAll "application" "cinder_volume" "container" "init_cinder_conf" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
128 image: {{ .Values.images.tags.ks_user }}
129 imagePullPolicy: {{ .Values.images.pull_policy }}
130 command:
131 - /tmp/retrieve-internal-tenant.sh
132 volumeMounts:
133 - name: pod-tmp
134 mountPath: /tmp
135 - name: cinder-bin
136 mountPath: /tmp/retrieve-internal-tenant.sh
137 subPath: retrieve-internal-tenant.sh
138 readOnly: true
139 - name: pod-shared
140 mountPath: /tmp/pod-shared
Oleksandr Kozachenkoa10d7852023-02-02 22:01:16 +0100141{{- dict "enabled" (or .Values.manifests.certificates .Values.tls.identity) "name" .Values.secrets.tls.volume.api.internal | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500142 env:
Mohammed Naserbcdd25c2023-01-18 03:38:47 +0000143{{- with $env := dict "ksUserSecret" .Values.secrets.identity.admin "useCA" (or .Values.manifests.certificates .Values.tls.identity) }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500144{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 12 }}
145{{- end }}
146 - name: INTERNAL_PROJECT_NAME
147 value: {{ .Values.conf.cinder.DEFAULT.internal_project_name | quote }}
148 - name: INTERNAL_USER_NAME
149 value: {{ .Values.conf.cinder.DEFAULT.internal_user_name | quote }}
150{{- with $env := dict "ksUserSecret" (index .Values.secrets.identity "cinder" ) }}
151{{- include "helm-toolkit.snippets.keystone_user_create_env_vars" $env | indent 12 }}
152{{- end }}
153 containers:
154 - name: cinder-volume
155{{ tuple $envAll "cinder_volume" | include "helm-toolkit.snippets.image" | indent 10 }}
156{{ tuple $envAll $envAll.Values.pod.resources.volume | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
157{{ dict "envAll" $envAll "application" "cinder_volume" "container" "cinder_volume" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
158 command:
159 - /tmp/cinder-volume.sh
Mohammed Naserbcdd25c2023-01-18 03:38:47 +0000160 env:
161{{- if or .Values.manifests.certificates .Values.tls.identity }}
162 - name: REQUESTS_CA_BUNDLE
163 value: "/etc/cinder/certs/ca.crt"
164{{- end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500165 terminationMessagePath: /var/log/termination-log
166 volumeMounts:
167 - name: pod-tmp
168 mountPath: /tmp
169 - name: cinder-bin
170 mountPath: /tmp/cinder-volume.sh
171 subPath: cinder-volume.sh
172 readOnly: true
173 - name: pod-shared
174 mountPath: /tmp/pod-shared
175 - name: cinder-conversion
176 mountPath: /var/lib/cinder/conversion
177 - name: cinder-etc
178 mountPath: /etc/cinder/cinder.conf
179 subPath: cinder.conf
180 readOnly: true
181 {{- if .Values.conf.cinder.DEFAULT.log_config_append }}
182 - name: cinder-etc
183 mountPath: {{ .Values.conf.cinder.DEFAULT.log_config_append }}
184 subPath: {{ base .Values.conf.cinder.DEFAULT.log_config_append }}
185 readOnly: true
186 {{- end }}
187 - name: cinder-etc
188 mountPath: /etc/cinder/conf/backends.conf
189 subPath: backends.conf
190 readOnly: true
191 {{- if eq "true" (include "cinder.utils.has_ceph_backend" $envAll) }}
192 - name: etcceph
193 mountPath: /etc/ceph
194 - name: ceph-etc
195 mountPath: /etc/ceph/ceph.conf
196 subPath: ceph.conf
197 readOnly: true
198 - name: ceph-keyring
199 mountPath: /tmp/client-keyring
200 subPath: key
201 readOnly: true
202 {{- if .Values.ceph_client.enable_external_ceph_backend }}
Mohammed Naserbcdd25c2023-01-18 03:38:47 +0000203 {{- if .Values.ceph_client.external_ceph.configmap }}
204 - name: external-ceph-etc
205 mountPath: /etc/ceph/external-ceph.conf
206 subPath: external-ceph.conf
207 readOnly: true
208 {{- else }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500209 - name: cinder-etc
210 mountPath: /etc/ceph/external-ceph.conf
211 subPath: external-ceph.conf
212 readOnly: true
Mohammed Naserbcdd25c2023-01-18 03:38:47 +0000213 {{- end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500214 {{- if .Values.ceph_client.external_ceph.rbd_user }}
215 - name: external-ceph-keyring
216 mountPath: /tmp/external-ceph-client-keyring
217 subPath: key
218 readOnly: true
219 {{- end }}
220 {{- end }}
221 {{- end }}
222 {{- if eq ( split "://" .Values.conf.cinder.coordination.backend_url )._0 "file" }}
223 - name: cinder-coordination
224 mountPath: {{ ( split "://" .Values.conf.cinder.coordination.backend_url )._1 }}
225 {{- end }}
226 - name: cinder-etc
227 # NOTE (Portdirect): We mount here to override Kollas
228 # custom sudoers file when using Kolla images, this
229 # location will also work fine for other images.
230 mountPath: /etc/sudoers.d/kolla_cinder_sudoers
231 subPath: cinder_sudoers
232 readOnly: true
233 - name: cinder-etc
234 mountPath: /etc/sudoers.d/kolla_cinder_volume_sudoers
235 subPath: cinder_sudoers
236 readOnly: true
237 - name: cinder-etc
238 mountPath: /etc/cinder/rootwrap.conf
239 subPath: rootwrap.conf
240 readOnly: true
241 {{- range $key, $value := $envAll.Values.conf.rootwrap_filters }}
242 {{- if ( has "volume" $value.pods ) }}
243 {{- $filePrefix := replace "_" "-" $key }}
244 {{- $rootwrapFile := printf "/etc/cinder/rootwrap.d/%s.filters" $filePrefix }}
245 - name: cinder-etc
246 mountPath: {{ $rootwrapFile }}
247 subPath: {{ base $rootwrapFile }}
248 readOnly: true
249 {{- end }}
250 {{- end }}
Dong Ma0a05b5c2024-11-24 13:27:29 +0800251 {{- range $key, $backend := .Values.conf.backends }}
252 {{- if $backend.nfs_shares_config }}
253 - name: cinder-etc
254 mountPath: /etc/cinder/nfs/{{ $key }}
255 subPath: nfs-{{ $key }}
256 readOnly: true
257 {{- end }}
258 {{- end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500259 {{- if .Values.conf.enable_iscsi }}
260 - name: host-rootfs
261 mountPath: /mnt/host-rootfs
262 {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }}
263 mountPropagation: HostToContainer
264 {{- end }}
265 - name: host-dev
266 mountPath: /dev
267 {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }}
268 mountPropagation: HostToContainer
269 {{- end }}
270 - name: runlock
271 mountPath: /run/lock
272 - name: etciscsi
273 mountPath: /etc/iscsi
274 {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }}
275 mountPropagation: HostToContainer
276 {{- end }}
277 - name: usrlocalsbin
278 mountPath: /usr/local/sbin
279 - name: cinder-bin
280 mountPath: /usr/local/sbin/iscsiadm
281 subPath: iscsiadm
282 - name: cinder-bin
283 mountPath: /usr/local/sbin/multipath
284 subPath: multipath
285 - name: cinder-bin
286 mountPath: /usr/local/sbin/multipathd
287 subPath: multipathd
288 - name: etcmultipath
289 mountPath: /etc/multipath
290 {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }}
291 mountPropagation: Bidirectional
292 {{- end }}
293 - name: sys
294 mountPath: /sys
295 {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }}
296 mountPropagation: HostToContainer
297 {{- end }}
298 {{- end }}
Oleksandr Kozachenkoa10d7852023-02-02 22:01:16 +0100299{{- dict "enabled" (or .Values.manifests.certificates .Values.tls.identity) "name" .Values.secrets.tls.volume.api.internal "path" "/etc/cinder/certs" | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500300{{- 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 12 }}
301{{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_messaging.auth.admin.secret.tls.internal "path" "/etc/rabbitmq/certs" | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }}
302{{ if $mounts_cinder_volume.volumeMounts }}{{ toYaml $mounts_cinder_volume.volumeMounts | indent 12 }}{{ end }}
303 volumes:
304 - name: pod-tmp
305 emptyDir: {}
306 - name: cinder-bin
307 configMap:
308 name: cinder-bin
309 defaultMode: 0555
310 - name: cinder-etc
311 secret:
312 secretName: cinder-etc
313 defaultMode: 0444
314 - name: pod-shared
315 emptyDir: {}
316 - name: cinder-conversion
317 emptyDir: {}
318 {{- if eq "true" (include "cinder.utils.has_ceph_backend" $envAll) }}
319 - name: etcceph
320 emptyDir: {}
321 - name: ceph-etc
322 configMap:
323 name: {{ .Values.ceph_client.configmap }}
324 defaultMode: 0444
Mohammed Naserbcdd25c2023-01-18 03:38:47 +0000325 {{- if and .Values.ceph_client.enable_external_ceph_backend .Values.ceph_client.external_ceph.configmap }}
326 - name: external-ceph-etc
327 configMap:
328 name: {{ .Values.ceph_client.external_ceph.configmap }}
329 defaultMode: 0444
330 {{- end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500331 - name: ceph-keyring
332 secret:
333 secretName: {{ .Values.secrets.rbd.volume | quote }}
334 {{- if and .Values.ceph_client.enable_external_ceph_backend .Values.ceph_client.external_ceph.rbd_user }}
335 - name: external-ceph-keyring
336 secret:
337 secretName: {{ .Values.secrets.rbd.volume_external | quote }}
338 {{ end }}
339 {{ end }}
340 {{- if eq ( split "://" .Values.conf.cinder.coordination.backend_url )._0 "file" }}
341 # NOTE (portdirect): this will need to be set to a shared mount amongst all cinder
342 # pods for the coordination backend to be fully functional.
343 - name: cinder-coordination
344 emptyDir: {}
345 {{- end }}
346 {{- if .Values.conf.enable_iscsi }}
347 - name: host-rootfs
348 hostPath:
349 path: /
350 - name: host-dev
351 hostPath:
352 path: /dev
353 - name: runlock
354 hostPath:
355 path: /run/lock
356 - name: etciscsi
357 hostPath:
358 path: /etc/iscsi
359 - name: usrlocalsbin
360 emptyDir: {}
361 - name: etcmultipath
362 hostPath:
363 path: /etc/multipath
364 - name: sys
365 hostPath:
366 path: /sys
367 {{- end }}
368{{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_db.auth.admin.secret.tls.internal | include "helm-toolkit.snippets.tls_volume" | indent 8 }}
Oleksandr Kozachenkoa10d7852023-02-02 22:01:16 +0100369{{- dict "enabled" (or .Values.manifests.certificates .Values.tls.identity) "name" .Values.secrets.tls.volume.api.internal | include "helm-toolkit.snippets.tls_volume" | indent 8 }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -0500370{{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_messaging.auth.admin.secret.tls.internal | include "helm-toolkit.snippets.tls_volume" | indent 8 }}
371{{ if $mounts_cinder_volume.volumes }}{{ toYaml $mounts_cinder_volume.volumes | indent 8 }}{{ end }}
372{{- end }}