[OOM] Fixing k8s ServiceAccounts
[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       - name: {{ include "common.name" . }}-readiness
27         command:
28         - /app/ready.py
29         args:
30         - --container-name
31         - {{.Values.elasticsearch.nameOverride}}-elasticsearch
32         - --container-name
33         - {{.Values.elasticsearch.nameOverride}}-nginx
34         - --container-name
35         - {{.Values.elasticsearch.nameOverride}}-master
36         env:
37         - name: NAMESPACE
38           valueFrom:
39             fieldRef:
40               apiVersion: v1
41               fieldPath: metadata.namespace
42         image: {{ include "repositoryGenerator.image.readiness" . }}
43         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
44       containers:
45       - name: {{ include "common.name" . }}-sdnrdb-init-job
46         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
47         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
48         command: ["/bin/bash"]
49         args:
50           - -c
51           - |
52             sleep 90; "{{ .Values.config.binDir }}/startODL.sh"
53         env:
54           - name: SDNC_AAF_ENABLED
55             value: "false"
56           - name: SDNC_HOME
57             value: "{{.Values.config.sdncHome}}"
58           - name: ETC_DIR
59             value: "{{.Values.config.etcDir}}"
60           - name: BIN_DIR
61             value: "{{.Values.config.binDir}}"
62           ## start sdnrdb parameter
63           - name: SDNRINIT
64             value: "true"
65           - name: SDNRDBURL
66             value: "http://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
67           - name: SDNRDBPARAMETER
68             value: "-k"
69         resources: {{ include "common.resources" . | nindent 10 }}
70       {{- if include "common.onServiceMesh" . }}
71       - name: sdnrdb-service-mesh-wait-for-job-container
72         image: {{ include "repositoryGenerator.image.quitQuit" . }}
73         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74         command:
75           - /bin/sh
76           - "-c"
77         args:
78           - |
79             echo "waiting 30s for istio side cars to be up"; sleep 30s;
80             /app/ready.py --service-mesh-check sdnc-sdnrdb-init-job -t 45;
81         env:
82         - name: NAMESPACE
83           valueFrom:
84             fieldRef:
85               apiVersion: v1
86               fieldPath: metadata.namespace
87       {{- end }}
88       {{- if .Values.nodeSelector }}
89       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
90       {{- end -}}
91       {{- if .Values.affinity }}
92       affinity: {{ toYaml .Values.affinity | nindent 10 }}
93       {{- end }}
94       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
95       volumes:
96       - name: localtime
97         hostPath:
98           path: /etc/localtime
99       - name: docker-entrypoint-initdb-d
100         emptyDir: {}
101       - name: bin
102         configMap:
103           name: {{ include "common.fullname" . }}-bin
104           defaultMode: 0755
105       - name: properties
106         configMap:
107           name: {{ include "common.fullname" . }}-properties
108           defaultMode: 0644
109       restartPolicy: Never
110       imagePullSecrets:
111       - name: "{{ include "common.namespace" . }}-docker-registry-key"
112
113 {{ end -}}