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