cb8d7574db128bd2198d6c89c33f63e371e53d80
[oom.git] / kubernetes / sdnc / templates / sdnrdb-init-job.yaml
1 {{/*
2 # Copyright © 2020 highstreet technologies GmbH
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16 {{ if .Values.config.sdnr.enabled -}}
17 apiVersion: batch/v1
18 kind: Job
19 metadata: {{- include "common.resourceMetadata" (dict "suffix" "sdnrdb-init-job" "dot" . ) | nindent 2 }}
20 spec:
21   backoffLimit: 20
22   template:
23     metadata: {{ include "common.templateMetadata" . | indent 6}}
24     spec:
25       initContainers:
26       {{ include "common.certInitializer.initContainer" . | indent 6 }}
27       {{ if .Values.global.aafEnabled }}
28       - name: {{ include "common.name" . }}-chown
29         image: {{ include "repositoryGenerator.image.busybox" . }}
30         command: ["sh", "-c", "chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}"]
31         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
32       {{ end }}
33       - name: {{ include "common.name" . }}-readiness
34         command:
35         - /app/ready.py
36         args:
37         - --container-name
38         - {{.Values.elasticsearch.nameOverride}}-elasticsearch
39         - --container-name
40         - {{.Values.elasticsearch.nameOverride}}-nginx
41         - --container-name
42         - {{.Values.elasticsearch.nameOverride}}-master
43         env:
44         - name: NAMESPACE
45           valueFrom:
46             fieldRef:
47               apiVersion: v1
48               fieldPath: metadata.namespace
49         image: {{ include "repositoryGenerator.image.readiness" . }}
50         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
51       containers:
52       - name: {{ include "common.name" . }}-sdnrdb-init-job
53         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
54         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55         command: ["/bin/bash"]
56         args: ["-c", "{{ .Values.config.binDir }}/startODL.sh"]
57         env:
58           - name: SDNC_AAF_ENABLED
59             value: "{{ .Values.global.aafEnabled}}"
60           - name: SDNC_HOME
61             value: "{{.Values.config.sdncHome}}"
62           - name: ETC_DIR
63             value: "{{.Values.config.etcDir}}"
64           - name: BIN_DIR
65             value: "{{.Values.config.binDir}}"
66           ## start sdnrdb parameter
67           - name: SDNRINIT
68             value: "true"
69           - name: SDNRDBURL
70             {{ if .Values.global.aafEnabled -}}
71             value: "https://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
72             {{- else -}}
73             value: "http://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
74             {{- end }}
75           - name: SDNRDBPARAMETER
76             value: "-k"
77         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
78         resources: {{ include "common.resources" . | nindent 12 }}
79       {{- if .Values.nodeSelector }}
80       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
81       {{- end -}}
82       {{- if .Values.affinity }}
83       affinity: {{ toYaml .Values.affinity | nindent 10 }}
84       {{- end }}
85       volumes:
86       - name: localtime
87         hostPath:
88           path: /etc/localtime
89       - name: docker-entrypoint-initdb-d
90         emptyDir: {}
91       - name: bin
92         configMap:
93           name: {{ include "common.fullname" . }}-bin
94           defaultMode: 0755
95       - name: properties
96         configMap:
97           name: {{ include "common.fullname" . }}-properties
98           defaultMode: 0644
99 {{ include "common.certInitializer.volumes" . | nindent 6 }}
100       restartPolicy: Never
101       imagePullSecrets:
102       - name: "{{ include "common.namespace" . }}-docker-registry-key"
103
104 {{ end -}}