Upgrade AAI to use common shared Cassandra
[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         {{- if .Values.global.cassandra.localCluster }}
59         - aai-cassandra
60         {{- else }}
61         - cassandra
62         {{- end }}
63         - --container-name
64         - aai-schema-service
65         env:
66         - name: NAMESPACE
67           valueFrom:
68             fieldRef:
69               apiVersion: v1
70               fieldPath: metadata.namespace
71         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
72         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
73         name: {{ include "common.name" . }}-readiness
74       containers:
75       - name: {{ include "common.name" . }}-job
76         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
77         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         command:
79         - /bin/bash
80         - docker-entrypoint.sh
81         - createDBSchema.sh
82         env:
83         - name: LOCAL_USER_ID
84           value: {{ .Values.global.config.userId | quote }}
85         - name: LOCAL_GROUP_ID
86           value: {{ .Values.global.config.groupId | quote }}
87         volumeMounts:
88         - mountPath: /etc/localtime
89           name: localtime
90           readOnly: true
91         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
92           name: {{ include "common.fullname" . }}-db-real-conf
93           subPath: janusgraph-realtime.properties
94         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
95           name: {{ include "common.fullname" . }}-db-cached-conf
96           subPath: janusgraph-cached.properties
97         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
98           name: {{ include "common.fullname" . }}-aaiconfig-conf
99           subPath: aaiconfig.properties
100         - mountPath: /opt/aai/logroot/AAI-GA
101           name: {{ include "common.fullname" . }}-logs
102         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
103           name: {{ include "common.fullname" . }}-log-conf
104           subPath: logback.xml
105         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
106           name: {{ include "common.fullname" . }}-localhost-access-log-conf
107           subPath: localhost-access-logback.xml
108         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
109           name: {{ include "common.fullname" . }}-springapp-conf
110           subPath: application.properties
111           {{ $global := . }}
112           {{ range $job := .Values.global.config.auth.files }}
113         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/{{ . }}
114           name: {{ include "common.fullname" $global }}-auth-truststore-sec
115           subPath: {{ . }}
116           {{ end }}
117         resources:
118 {{ include "common.resources" . }}
119       {{- if .Values.nodeSelector }}
120       nodeSelector:
121 {{ toYaml .Values.nodeSelector | indent 8 }}
122       {{- end -}}
123       {{- if .Values.affinity }}
124       affinity:
125 {{ toYaml .Values.affinity | indent 8 }}
126       {{- end }}
127       volumes:
128       - name: localtime
129         hostPath:
130           path: /etc/localtime
131       - name: filebeat-conf
132         configMap:
133           name: aai-filebeat
134       - name: {{ include "common.fullname" . }}-logs
135         hostPath:
136           path: {{ .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }}-create-db-schema
137       - name: {{ include "common.fullname" . }}-filebeat
138         emptyDir: {}
139       - name: {{ include "common.fullname" . }}-log-conf
140         configMap:
141          name: {{ include "common.fullname" . }}-log
142       - name: {{ include "common.fullname" . }}-localhost-access-log-conf
143         configMap:
144          name: {{ include "common.fullname" . }}-localhost-access-log-configmap
145       - name: {{ include "common.fullname" . }}-db-real-conf
146         configMap:
147          name: {{ include "common.fullname" . }}-db-real-configmap
148       - name: {{ include "common.fullname" . }}-db-cached-conf
149         configMap:
150          name: {{ include "common.fullname" . }}-db-cached-configmap
151       - name: {{ include "common.fullname" . }}-aaiconfig-conf
152         configMap:
153          name: {{ include "common.fullname" . }}-aaiconfig-configmap
154       - name: {{ include "common.fullname" . }}-springapp-conf
155         configMap:
156          name: {{ include "common.fullname" . }}-springapp-configmap
157       - name: {{ include "common.fullname" . }}-realm-conf
158         configMap:
159          name: {{ include "common.fullname" . }}-realm-configmap
160       - name: {{ include "common.fullname" . }}-auth-truststore-sec
161         secret:
162          secretName: aai-common-truststore
163          items:
164           {{ range $job := .Values.global.config.auth.files }}
165            - key: {{ . }}
166              path: {{ . }}
167           {{ end }}
168       restartPolicy: Never
169       imagePullSecrets:
170       - name: "{{ include "common.namespace" . }}-docker-registry-key"
171 {{ end }}