blob: 4b2f773f061e90e59edbaf87c655a2d4a6a3f72a [file] [log] [blame]
Jakub Latuseke0e8ca72020-10-21 13:36:29 +02001{{/*
Alexander Dehn9b797d62020-04-21 09:53:50 +00002# 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.
Jakub Latuseke0e8ca72020-10-21 13:36:29 +020015*/}}
Alexander Dehn9b797d62020-04-21 09:53:50 +000016{{ if .Values.config.sdnr.enabled -}}
17apiVersion: batch/v1
18kind: Job
19metadata: {{- include "common.resourceMetadata" (dict "suffix" "sdnrdb-init-job" "dot" . ) | nindent 2 }}
20spec:
21 backoffLimit: 20
22 template:
23 metadata: {{ include "common.templateMetadata" . | indent 6}}
24 spec:
25 initContainers:
Alexander Dehn9b797d62020-04-21 09:53:50 +000026 - name: {{ include "common.name" . }}-readiness
27 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020028 - /app/ready.py
Alexander Dehn9b797d62020-04-21 09:53:50 +000029 args:
demskeq84e1f84c2023-07-04 08:39:43 +000030 {{- if .Values.config.sdnr.mariadb.enabled }}
31 - --container-name
32 - {{ include "common.mariadbService" . }}
33 {{- else -}}
Alexander Dehn9b797d62020-04-21 09:53:50 +000034 - --container-name
35 - {{.Values.elasticsearch.nameOverride}}-elasticsearch
36 - --container-name
37 - {{.Values.elasticsearch.nameOverride}}-nginx
38 - --container-name
39 - {{.Values.elasticsearch.nameOverride}}-master
demskeq84e1f84c2023-07-04 08:39:43 +000040 {{- end }}
Alexander Dehn9b797d62020-04-21 09:53:50 +000041 env:
42 - name: NAMESPACE
43 valueFrom:
44 fieldRef:
45 apiVersion: v1
46 fieldPath: metadata.namespace
Sylvain Desbureauxcbc703c2020-11-19 17:52:07 +010047 image: {{ include "repositoryGenerator.image.readiness" . }}
Alexander Dehn9b797d62020-04-21 09:53:50 +000048 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
49 containers:
50 - name: {{ include "common.name" . }}-sdnrdb-init-job
Sylvain Desbureauxcbc703c2020-11-19 17:52:07 +010051 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
Alexander Dehn9b797d62020-04-21 09:53:50 +000052 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
53 command: ["/bin/bash"]
Radoslaw Chmiel58662a32022-06-02 19:37:35 +020054 args:
55 - -c
56 - |
demskeq84e1f84c2023-07-04 08:39:43 +000057 {{- if .Values.config.sdnr.mariadb.enabled }}
58 "{{ .Values.config.binDir }}/createSdnrDb.sh";
59 {{- end -}}
Radoslaw Chmiel58662a32022-06-02 19:37:35 +020060 sleep 90; "{{ .Values.config.binDir }}/startODL.sh"
Alexander Dehn9b797d62020-04-21 09:53:50 +000061 env:
62 - name: SDNC_AAF_ENABLED
Andreas Geissler2af50792023-03-27 17:11:27 +020063 value: "false"
Alexander Dehn9b797d62020-04-21 09:53:50 +000064 - name: SDNC_HOME
65 value: "{{.Values.config.sdncHome}}"
66 - name: ETC_DIR
67 value: "{{.Values.config.etcDir}}"
68 - name: BIN_DIR
69 value: "{{.Values.config.binDir}}"
70 ## start sdnrdb parameter
71 - name: SDNRINIT
72 value: "true"
demskeq84e1f84c2023-07-04 08:39:43 +000073 {{- if .Values.config.sdnr.mariadb.enabled }}
74 - name: SDNRDBTYPE
75 value: MARIADB
76 - name: MYSQL_HOST
77 value: {{ include "common.mariadbService" . }}
78 - name: MYSQL_ROOT_PASSWORD
79 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
80 - name: SDNRDBURL
81 value: "jdbc:mysql://{{ include "common.mariadbService" . }}:3306/{{ .Values.config.sdnr.mariadb.databaseName }}"
82 - name: SDNRDBDATABASE
83 value: "{{ .Values.config.sdnr.mariadb.databaseName }}"
84 - name: SDNRDBUSERNAME
85 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdnrdb-secret" "key" "login") | indent 12 }}
86 - name: SDNRDBPASSWORD
87 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdnrdb-secret" "key" "password") | indent 12 }}
88 {{- else -}}
Alexander Dehn9b797d62020-04-21 09:53:50 +000089 - name: SDNRDBURL
Alexander Dehn9b797d62020-04-21 09:53:50 +000090 value: "http://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
Alexander Dehn9b797d62020-04-21 09:53:50 +000091 - name: SDNRDBPARAMETER
92 value: "-k"
demskeq84e1f84c2023-07-04 08:39:43 +000093 {{- end }}
94 {{- if .Values.config.sdnr.mariadb.enabled }}
95 volumeMounts:
96 - mountPath: {{ .Values.config.binDir }}/createSdnrDb.sh
97 name: bin
98 subPath: createSdnrDb.sh
99 {{- end }}
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100100 resources: {{ include "common.resources" . | nindent 10 }}
Radoslaw Chmiel58662a32022-06-02 19:37:35 +0200101 {{- if include "common.onServiceMesh" . }}
102 - name: sdnrdb-service-mesh-wait-for-job-container
103 image: {{ include "repositoryGenerator.image.quitQuit" . }}
104 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
105 command:
106 - /bin/sh
107 - "-c"
108 args:
109 - |
110 echo "waiting 30s for istio side cars to be up"; sleep 30s;
111 /app/ready.py --service-mesh-check sdnc-sdnrdb-init-job -t 45;
112 env:
113 - name: NAMESPACE
114 valueFrom:
115 fieldRef:
116 apiVersion: v1
117 fieldPath: metadata.namespace
118 {{- end }}
Alexander Dehn9b797d62020-04-21 09:53:50 +0000119 {{- if .Values.nodeSelector }}
120 nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
121 {{- end -}}
122 {{- if .Values.affinity }}
123 affinity: {{ toYaml .Values.affinity | nindent 10 }}
124 {{- end }}
vladimir turokd8044182023-07-27 16:28:36 +0200125 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Alexander Dehn9b797d62020-04-21 09:53:50 +0000126 volumes:
127 - name: localtime
128 hostPath:
129 path: /etc/localtime
130 - name: docker-entrypoint-initdb-d
131 emptyDir: {}
132 - name: bin
133 configMap:
134 name: {{ include "common.fullname" . }}-bin
135 defaultMode: 0755
136 - name: properties
137 configMap:
138 name: {{ include "common.fullname" . }}-properties
139 defaultMode: 0644
Alexander Dehn9b797d62020-04-21 09:53:50 +0000140 restartPolicy: Never
141 imagePullSecrets:
142 - name: "{{ include "common.namespace" . }}-docker-registry-key"
143
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +0200144{{ end -}}