blob: 928c1831fce3d8042113b8d5048db84ba6950f91 [file] [log] [blame]
okozachenko120361008f72023-03-23 21:21:09 +11001{{/*
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.global).subchart_release_name }}
16{{- $_ := set . "deployment_name" .Chart.Name }}
17{{- else }}
18{{- $_ := set . "deployment_name" .Release.Name }}
19{{- end }}
20
21{{- if .Values.manifests.pod_rally_test }}
22{{- $envAll := . }}
23
24{{- $mounts_tests := .Values.pod.mounts.manila_tests.manila_tests }}
25{{- $mounts_tests_init := .Values.pod.mounts.manila_tests.init_container }}
26
27{{- $serviceAccountName := print $envAll.deployment_name "-test" }}
28{{ tuple $envAll "tests" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
29---
30apiVersion: v1
31kind: Pod
32metadata:
33 name: {{ print $envAll.deployment_name "-test" }}
34 labels:
35{{ tuple $envAll "manila" "test" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
36 annotations:
37 "helm.sh/hook": test-success
38 {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
39{{ dict "envAll" $envAll "podName" "manila-test" "containerNames" (list "init" "manila-test" "manila-test-ks-user") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 4 }}
40spec:
41 restartPolicy: Never
42{{ dict "envAll" $envAll "application" "test" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 2 }}
43 nodeSelector:
44 {{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }}
45 serviceAccountName: {{ $serviceAccountName }}
46 initContainers:
47{{ tuple $envAll "tests" $mounts_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }}
48 - name: manila-test-ks-user
49{{ tuple $envAll "ks_user" | include "helm-toolkit.snippets.image" | indent 6 }}
50{{ tuple $envAll $envAll.Values.pod.resources.jobs.ks_user | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }}
51{{ dict "envAll" $envAll "application" "test" "container" "manila_test_ks_user" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 6 }}
52 command:
53 - /tmp/ks-user.sh
54 volumeMounts:
55 - name: pod-tmp
56 mountPath: /tmp
57 - name: manila-bin
58 mountPath: /tmp/ks-user.sh
59 subPath: ks-user.sh
60 readOnly: true
61{{- if and .Values.manifests.certificates .Values.secrets.tls.share.api.internal }}
62{{- dict "enabled" .Values.manifests.certificates "name" .Values.secrets.tls.share.api.internal | include "helm-toolkit.snippets.tls_volume_mount" | indent 8 }}
63{{- end }}
64 env:
65{{- with $env := dict "ksUserSecret" .Values.secrets.share.admin "useCA" (and .Values.manifests.certificates .Values.secrets.tls.share.api.internal) }}
66{{- include "helm-toolkit.snippets.manila_openrc_env_vars" $env | indent 8 }}
67{{- end }}
68 - name: SERVICE_OS_SERVICE_NAME
69 value: "test"
70{{- with $env := dict "ksUserSecret" .Values.secrets.share.test }}
71{{- include "helm-toolkit.snippets.manila_user_create_env_vars" $env | indent 8 }}
72{{- end }}
73 - name: SERVICE_OS_ROLE
74 value: {{ .Values.endpoints.share.auth.test.role | quote }}
75 containers:
76 - name: manila-test
77{{ tuple $envAll "test" | include "helm-toolkit.snippets.image" | indent 6 }}
78{{ tuple $envAll $envAll.Values.pod.resources.jobs.tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }}
79{{ dict "envAll" $envAll "application" "test" "container" "manila_test" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 6}}
80 env:
81{{- with $env := dict "ksUserSecret" .Values.secrets.share.admin "useCA" (and .Values.manifests.certificates .Values.secrets.tls.share.api.internal) }}
82{{- include "helm-toolkit.snippets.manila_openrc_env_vars" $env | indent 8 }}
83{{- end }}
84{{- with $env := dict "ksUserSecret" .Values.secrets.share.test }}
85{{- include "helm-toolkit.snippets.manila_user_create_env_vars" $env | indent 8 }}
86{{- end }}
87 - name: RALLY_ENV_NAME
88 value: {{.deployment_name}}
89 command:
90 - /tmp/rally-test.sh
91 volumeMounts:
92 - name: pod-tmp
93 mountPath: /tmp
94 - name: manila-etc
95 mountPath: /etc/rally/rally_tests.yaml
96 subPath: rally_tests.yaml
97 readOnly: true
98 - name: manila-bin
99 mountPath: /tmp/rally-test.sh
100 subPath: rally-test.sh
101 readOnly: true
102 - name: rally-db
103 mountPath: /var/lib/rally
104 - name: rally-work
105 mountPath: /home/rally/.rally
106{{- if and .Values.manifests.certificates .Values.secrets.tls.share.api.internal }}
107{{- dict "enabled" .Values.manifests.certificates "name" .Values.secrets.tls.share.api.internal | include "helm-toolkit.snippets.tls_volume_mount" | indent 8 }}
108{{- end }}
109{{ if $mounts_tests.volumeMounts }}{{ toYaml $mounts_tests.volumeMounts | indent 8 }}{{ end }}
110 volumes:
111 - name: pod-tmp
112 emptyDir: {}
113 - name: manila-etc
114 secret:
115 secretName: manila-etc
116 defaultMode: 0444
117 - name: manila-bin
118 configMap:
119 name: manila-bin
120 defaultMode: 0555
121 - name: rally-db
122 emptyDir: {}
123 - name: rally-work
124 emptyDir: {}
125{{- if and .Values.manifests.certificates .Values.secrets.tls.share.api.internal }}
126{{- dict "enabled" .Values.manifests.certificates "name" .Values.secrets.tls.share.api.internal | include "helm-toolkit.snippets.tls_volume" | indent 4 }}
127{{- end }}
128{{ if $mounts_tests.volumes }}{{ toYaml $mounts_tests.volumes | indent 4 }}{{ end }}
129{{- end }}