a62202ba3230c13b07632f0cfe07b21abc512238
[oom.git] / kubernetes / aai / charts / aai-graphadmin / templates / job.yaml
1 #
2 # ============LICENSE_START=======================================================
3 # org.onap.aai
4 # ================================================================================
5 # Copyright © 2018 AT&T Intellectual Property. All rights reserved.
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #    http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
19
20 # In ONAP, the following job will always be run on each installation
21 # The following job will go through the latest oxm and
22 # create properties based on the data type defined in the oxm
23 # and create the required indexes for the appropriate properties
24 # This can be run multiple times as the code if the index or property already exists
25 # then the index or property won't be created again
26 # NOTE - During the execution of the createSchema job, there should
27 # be no other janusgraph connection to the graph as its the reason
28 # that resources traversal and graphadmin wait until this job is done
29 # If you are using an existing cassandra cluster not coming from oom
30 # then it is your job to ensure that there are no connections to the database
31
32 {{ if .Values.global.jobs.createSchema.enabled }}
33
34 apiVersion: batch/v1
35 kind: Job
36 metadata:
37   name: {{ include "common.fullname" . }}-create-db-schema
38   namespace: {{ include "common.namespace" . }}
39   labels:
40     app: {{ include "common.name" . }}-job
41     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
42     release: {{ .Release.Name }}
43     heritage: {{ .Release.Service }}
44 spec:
45   backoffLimit: 20
46   template:
47     metadata:
48       labels:
49         app: {{ include "common.name" . }}-job
50         release: {{ .Release.Name }}
51       name: {{ include "common.name" . }}
52     spec:
53       initContainers:
54       - command:
55         - /root/ready.py
56         args:
57         - --container-name
58         - aai-cassandra
59         - --container-name
60         - aai-schema-service
61         env:
62         - name: NAMESPACE
63           valueFrom:
64             fieldRef:
65               apiVersion: v1
66               fieldPath: metadata.namespace
67         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
68         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
69         name: {{ include "common.name" . }}-readiness
70       containers:
71       - name: {{ include "common.name" . }}-job
72         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
73         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74         command:
75         - /bin/bash
76         - docker-entrypoint.sh
77         - createDBSchema.sh
78         env:
79         - name: LOCAL_USER_ID
80           value: {{ .Values.global.config.userId | quote }}
81         - name: LOCAL_GROUP_ID
82           value: {{ .Values.global.config.groupId | quote }}
83         volumeMounts:
84         - mountPath: /etc/localtime
85           name: localtime
86           readOnly: true
87         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
88           name: {{ include "common.fullname" . }}-db-real-conf
89           subPath: janusgraph-realtime.properties
90         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
91           name: {{ include "common.fullname" . }}-db-cached-conf
92           subPath: janusgraph-cached.properties
93         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
94           name: {{ include "common.fullname" . }}-aaiconfig-conf
95           subPath: aaiconfig.properties
96         - mountPath: /opt/aai/logroot/AAI-GA
97           name: {{ include "common.fullname" . }}-logs
98         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
99           name: {{ include "common.fullname" . }}-log-conf
100           subPath: logback.xml
101         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
102           name: {{ include "common.fullname" . }}-localhost-access-log-conf
103           subPath: localhost-access-logback.xml
104         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
105           name: {{ include "common.fullname" . }}-springapp-conf
106           subPath: application.properties
107           {{ $global := . }}
108           {{ range $job := .Values.global.config.auth.files }}
109         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/{{ . }}
110           name: {{ include "common.fullname" $global }}-auth-truststore-sec
111           subPath: {{ . }}
112           {{ end }}
113         resources:
114 {{ include "common.resources" . }}
115       {{- if .Values.nodeSelector }}
116       nodeSelector:
117 {{ toYaml .Values.nodeSelector | indent 8 }}
118       {{- end -}}
119       {{- if .Values.affinity }}
120       affinity:
121 {{ toYaml .Values.affinity | indent 8 }}
122       {{- end }}
123       volumes:
124       - name: localtime
125         hostPath:
126           path: /etc/localtime
127       - name: filebeat-conf
128         configMap:
129           name: aai-filebeat
130       - name: {{ include "common.fullname" . }}-logs
131         hostPath:
132           path: {{ .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }}-create-db-schema
133       - name: {{ include "common.fullname" . }}-filebeat
134         emptyDir: {}
135       - name: {{ include "common.fullname" . }}-log-conf
136         configMap:
137          name: {{ include "common.fullname" . }}-log
138       - name: {{ include "common.fullname" . }}-localhost-access-log-conf
139         configMap:
140          name: {{ include "common.fullname" . }}-localhost-access-log-configmap
141       - name: {{ include "common.fullname" . }}-db-real-conf
142         configMap:
143          name: {{ include "common.fullname" . }}-db-real-configmap
144       - name: {{ include "common.fullname" . }}-db-cached-conf
145         configMap:
146          name: {{ include "common.fullname" . }}-db-cached-configmap
147       - name: {{ include "common.fullname" . }}-aaiconfig-conf
148         configMap:
149          name: {{ include "common.fullname" . }}-aaiconfig-configmap
150       - name: {{ include "common.fullname" . }}-springapp-conf
151         configMap:
152          name: {{ include "common.fullname" . }}-springapp-configmap
153       - name: {{ include "common.fullname" . }}-realm-conf
154         configMap:
155          name: {{ include "common.fullname" . }}-realm-configmap
156       - name: {{ include "common.fullname" . }}-auth-truststore-sec
157         secret:
158          secretName: aai-common-truststore
159          items:
160           {{ range $job := .Values.global.config.auth.files }}
161            - key: {{ . }}
162              path: {{ . }}
163           {{ end }}
164       restartPolicy: Never
165       imagePullSecrets:
166       - name: "{{ include "common.namespace" . }}-docker-registry-key"
167 {{ end }}