[SDNC] SDNC ServiceMesh compatibility
[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:
57           - -c
58           - |
59             sleep 90; "{{ .Values.config.binDir }}/startODL.sh"
60         env:
61           - name: SDNC_AAF_ENABLED
62             value: "{{ .Values.global.aafEnabled}}"
63           - name: SDNC_HOME
64             value: "{{.Values.config.sdncHome}}"
65           - name: ETC_DIR
66             value: "{{.Values.config.etcDir}}"
67           - name: BIN_DIR
68             value: "{{.Values.config.binDir}}"
69           ## start sdnrdb parameter
70           - name: SDNRINIT
71             value: "true"
72           - name: SDNRDBURL
73             {{ if .Values.global.aafEnabled -}}
74             value: "https://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
75             {{- else -}}
76             value: "http://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
77             {{- end }}
78           - name: SDNRDBPARAMETER
79             value: "-k"
80         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
81         resources: {{ include "common.resources" . | nindent 12 }}
82       {{- if include "common.onServiceMesh" . }}
83       - name: sdnrdb-service-mesh-wait-for-job-container
84         image: {{ include "repositoryGenerator.image.quitQuit" . }}
85         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
86         command:
87           - /bin/sh
88           - "-c"
89         args:
90           - |
91             echo "waiting 30s for istio side cars to be up"; sleep 30s;
92             /app/ready.py --service-mesh-check sdnc-sdnrdb-init-job -t 45;
93         env:
94         - name: NAMESPACE
95           valueFrom:
96             fieldRef:
97               apiVersion: v1
98               fieldPath: metadata.namespace
99       {{- end }}
100       {{- if .Values.nodeSelector }}
101       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
102       {{- end -}}
103       {{- if .Values.affinity }}
104       affinity: {{ toYaml .Values.affinity | nindent 10 }}
105       {{- end }}
106       volumes:
107       - name: localtime
108         hostPath:
109           path: /etc/localtime
110       - name: docker-entrypoint-initdb-d
111         emptyDir: {}
112       - name: bin
113         configMap:
114           name: {{ include "common.fullname" . }}-bin
115           defaultMode: 0755
116       - name: properties
117         configMap:
118           name: {{ include "common.fullname" . }}-properties
119           defaultMode: 0644
120 {{ include "common.certInitializer.volumes" . | nindent 6 }}
121       restartPolicy: Never
122       imagePullSecrets:
123       - name: "{{ include "common.namespace" . }}-docker-registry-key"
124
125 {{ end -}}