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