Add graphadmin microservice to oom
[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       annotations:
53         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
54     spec:
55       initContainers:
56       - command:
57         - /root/ready.py
58         args:
59         - --container-name
60         - aai-cassandra
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" . }}
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-RES
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 {{ toYaml .Values.resources | indent 10 }}
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         emptyDir: {}
132       - name: {{ include "common.fullname" . }}-filebeat
133         emptyDir: {}
134       - name: {{ include "common.fullname" . }}-log-conf
135         configMap:
136          name: {{ include "common.fullname" . }}-log
137       - name: {{ include "common.fullname" . }}-localhost-access-log-conf
138         configMap:
139          name: {{ include "common.fullname" . }}-localhost-access-log-configmap
140       - name: {{ include "common.fullname" . }}-db-real-conf
141         configMap:
142          name: {{ include "common.fullname" . }}-db-real-configmap
143       - name: {{ include "common.fullname" . }}-db-cached-conf
144         configMap:
145          name: {{ include "common.fullname" . }}-db-cached-configmap
146       - name: {{ include "common.fullname" . }}-aaiconfig-conf
147         configMap:
148          name: {{ include "common.fullname" . }}-aaiconfig-configmap
149       - name: {{ include "common.fullname" . }}-springapp-conf
150         configMap:
151          name: {{ include "common.fullname" . }}-springapp-configmap
152       - name: {{ include "common.fullname" . }}-realm-conf
153         configMap:
154          name: {{ include "common.fullname" . }}-realm-configmap
155       - name: {{ include "common.fullname" . }}-auth-truststore-sec
156         secret:
157          secretName: aai-auth-truststore-secret
158          items:
159           {{ range $job := .Values.global.config.auth.files }}
160            - key: {{ . }}
161              path: {{ . }}
162           {{ end }}
163       restartPolicy: Never
164       imagePullSecrets:
165       - name: "{{ include "common.namespace" . }}-docker-registry-key"
166 {{ end }}