blob: c8710b639f330366f378664dbd3f7e444fd1a0bc [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_credential_setup }}
16{{- $envAll := . }}
17
18{{- $mounts_keystone_credential_setup := .Values.pod.mounts.keystone_credential_setup.keystone_credential_setup }}
19{{- $mounts_keystone_credential_setup_init := .Values.pod.mounts.keystone_credential_setup.init_container }}
20
21{{- $serviceAccountName := "keystone-credential-setup" }}
22{{ tuple $envAll "credential_setup" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
23---
24apiVersion: rbac.authorization.k8s.io/v1
25kind: Role
26metadata:
27 name: {{ $serviceAccountName }}
28rules:
29 - apiGroups:
30 - ""
31 resources:
32 - secrets
33 verbs:
34 - get
35 - list
36 - create
37 - update
38---
39apiVersion: rbac.authorization.k8s.io/v1
40kind: RoleBinding
41metadata:
42 name: {{ $serviceAccountName }}
43roleRef:
44 apiGroup: rbac.authorization.k8s.io
45 kind: Role
46 name: {{ $serviceAccountName }}
47subjects:
48 - kind: ServiceAccount
49 name: {{ $serviceAccountName }}
50 namespace: {{ $envAll.Release.Namespace }}
51---
52apiVersion: batch/v1
53kind: Job
54metadata:
55 name: keystone-credential-setup
56 labels:
57{{ tuple $envAll "keystone" "credential-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
58 annotations:
59{{- if .Values.helm3_hook }}
60 "helm.sh/hook": post-install,post-upgrade
61 "helm.sh/hook-weight": "-5"
62 "helm.sh/hook-delete-policy": before-hook-creation
63{{- end }}
64 {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
Oleksandr K.582fd5e2024-07-19 04:39:01 +020065{{ tuple "keystone_credential_setup" $envAll | include "helm-toolkit.snippets.custom_job_annotations" | indent 4 }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050066spec:
67 template:
68 metadata:
69 labels:
70{{ tuple $envAll "keystone" "credential-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
71 annotations:
72{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }}
73 configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }}
74 configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }}
75{{ dict "envAll" $envAll "podName" "keystone-credential-setup" "containerNames" (list "keystone-credential-setup") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }}
76 spec:
Dong Ma36b89222025-02-13 16:15:52 +000077{{ with .Values.pod.priorityClassName.keystone_credential_setup }}
78 priorityClassName: {{ . }}
79{{ end }}
80{{ with .Values.pod.runtimeClassName.keystone_credential_setup }}
81 runtimeClassName: {{ . }}
82{{ end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050083 serviceAccountName: {{ $serviceAccountName }}
84{{ dict "envAll" $envAll "application" "credential_setup" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
85 initContainers:
86{{ tuple $envAll "credential_setup" $mounts_keystone_credential_setup_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
87 restartPolicy: OnFailure
Oleksandr Kozachenkoa10d7852023-02-02 22:01:16 +010088{{ if $envAll.Values.pod.tolerations.keystone.enabled }}
89{{ tuple $envAll "keystone" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }}
90{{ end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050091 nodeSelector:
92 {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
93 containers:
94 - name: keystone-credential-setup
95{{ tuple $envAll "keystone_credential_setup" | include "helm-toolkit.snippets.image" | indent 10 }}
96{{ tuple $envAll $envAll.Values.pod.resources.jobs.credential_setup | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
97{{ dict "envAll" $envAll "application" "credential_setup" "container" "keystone_credential_setup" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
98 env:
99 - name: KEYSTONE_USER
100 value: {{ .Values.jobs.credential_setup.user | quote }}
101 - name: KEYSTONE_GROUP
102 value: {{ .Values.jobs.credential_setup.group | quote }}
103 - name: KUBERNETES_NAMESPACE
104 value: {{ .Release.Namespace | quote }}
105 - name: KEYSTONE_KEYS_REPOSITORY
106 value: {{ .Values.conf.keystone.credential.key_repository | quote }}
107 command:
108 - python
109 - /tmp/fernet-manage.py
110 - credential_setup
111 volumeMounts:
112 - name: pod-tmp
113 mountPath: /tmp
114 - name: etckeystone
115 mountPath: /etc/keystone
116 - name: credential-keys
117 mountPath: {{ .Values.conf.keystone.credential.key_repository | quote }}
118 - name: keystone-etc
119 mountPath: /etc/keystone/keystone.conf
120 subPath: keystone.conf
121 readOnly: true
122 {{- if .Values.conf.keystone.DEFAULT.log_config_append }}
123 - name: keystone-etc
124 mountPath: {{ .Values.conf.keystone.DEFAULT.log_config_append }}
125 subPath: {{ base .Values.conf.keystone.DEFAULT.log_config_append }}
126 readOnly: true
127 {{- end }}
128 - name: keystone-bin
129 mountPath: /tmp/fernet-manage.py
130 subPath: fernet-manage.py
131 readOnly: true
132{{ if $mounts_keystone_credential_setup.volumeMounts }}{{ toYaml $mounts_keystone_credential_setup.volumeMounts | indent 12 }}{{ end }}
133 volumes:
134 - name: pod-tmp
135 emptyDir: {}
136 - name: etckeystone
137 emptyDir: {}
138 - name: credential-keys
139 emptyDir: {}
140 - name: keystone-etc
141 secret:
142 secretName: keystone-etc
143 defaultMode: 0444
144 - name: keystone-bin
145 configMap:
146 name: keystone-bin
147 defaultMode: 0555
148{{ if $mounts_keystone_credential_setup.volumes }}{{ toYaml $mounts_keystone_credential_setup.volumes | indent 8 }}{{ end }}
149{{- end }}