AAI Rolling upgrade using helm hooks
[oom.git] / kubernetes / aai / charts / aai-traversal / templates / job.yaml
1 # Copyright © 2017-2018 AT&T
2 # Modifications Copyright © 2018 Amdocs, Bell Canada
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 {{ if .Values.global.jobs.updateQueryData.enabled }}
17
18 apiVersion: batch/v1
19 kind: Job
20 metadata:
21   name: {{ include "common.fullname" . }}-update-query-data
22   namespace: {{ include "common.namespace" . }}
23   labels:
24     app: {{ include "common.name" . }}
25     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26     release: {{ .Release.Name }}
27     heritage: {{ .Release.Service }}
28 {{ if .Values.global.jobs.migration.enabled }}
29   annotations:
30     "helm.sh/hook": post-upgrade,post-rollback,post-install
31     "helm.sh/hook-weight": "2"
32     "helm.sh/hook-delete-policy": before-hook-creation
33 {{ end }}
34 spec:
35   template:
36     metadata:
37       labels:
38         app: {{ include "common.name" . }}-job
39         release: {{ .Release.Name }}
40       name: {{ include "common.name" . }}
41     spec:
42       initContainers:
43       - command:
44         - /root/ready.py
45         args:
46         - --container-name
47         - aai
48         {{ if eq .Values.global.aafEnabled true }}
49         - --container-name
50         - aaf-locate
51         {{ end }}
52         env:
53         - name: NAMESPACE
54           valueFrom:
55             fieldRef:
56               apiVersion: v1
57               fieldPath: metadata.namespace
58         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
59         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
60         name: {{ include "common.name" . }}-readiness
61       containers:
62       - name: {{ include "common.name" . }}-job
63         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
64         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
65         command:
66         - bash
67         - "-c"
68         - |
69           set -x
70           mkdir -p /opt/aai/logroot/AAI-GQ/misc
71           until nc -w10 -z -v aai.{{.Release.Namespace}} 8443; do echo "Retrying to reach aai on port 8443"; done;
72           bash -x /opt/app/aai-traversal/docker-entrypoint.sh install/updateQueryData.sh
73         env:
74         - name: LOCAL_USER_ID
75           value: {{ .Values.global.config.userId | quote }}
76         - name: LOCAL_GROUP_ID
77           value: {{ .Values.global.config.groupId | quote }}
78         volumeMounts:
79         - mountPath: /etc/localtime
80           name: localtime
81           readOnly: true
82         - mountPath: /opt/app/aai-traversal/resources/etc/appprops/janusgraph-realtime.properties
83           name: {{ include "common.fullname" . }}-config
84           subPath: janusgraph-realtime.properties
85         - mountPath: /opt/app/aai-traversal/resources/etc/appprops/janusgraph-cached.properties
86           name: {{ include "common.fullname" . }}-config
87           subPath: janusgraph-cached.properties
88         - mountPath: /opt/app/aai-traversal/resources/etc/appprops/aaiconfig.properties
89           name: {{ include "common.fullname" . }}-config
90           subPath: aaiconfig.properties
91         - mountPath: /opt/aai/logroot/AAI-GQ/
92           name: {{ include "common.fullname" . }}-logs
93         - mountPath: /opt/app/aai-traversal/resources/logback.xml
94           name: {{ include "common.fullname" . }}-config
95           subPath: logback.xml
96         - mountPath: /opt/app/aai-traversal/resources/localhost-access-logback.xml
97           name: {{ include "common.fullname" . }}-config
98           subPath: localhost-access-logback.xml
99         - mountPath: /opt/app/aai-traversal/resources/application.properties
100           name: {{ include "common.fullname" . }}-config
101           subPath: application.properties
102           {{ $global := . }}
103           {{ range $job := .Values.global.config.auth.files }}
104         - mountPath: /opt/app/aai-traversal/resources/etc/auth/{{ . }}
105           name: {{ include "common.fullname" $global }}-auth-truststore-sec
106           subPath: {{ . }}
107           {{ end }}
108         # disable liveness probe when breakpoints set in debugger
109         # so K8s doesn't restart unresponsive container
110       volumes:
111       - name: localtime
112         hostPath:
113           path: /etc/localtime
114       - name: filebeat-conf
115         configMap:
116           name: aai-filebeat
117       - name: {{ include "common.fullname" . }}-logs
118         hostPath:
119           path: {{ .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }}-update-query
120       - name: {{ include "common.fullname" . }}-filebeat
121         emptyDir: {}
122       - name: {{ include "common.fullname" . }}-config
123         configMap:
124          name: {{ include "common.fullname" . }}-configmap
125       - name: {{ include "common.fullname" . }}-auth-truststore-sec
126         secret:
127          secretName: aai-common-truststore
128          items:
129           {{ range $job := .Values.global.config.auth.files }}
130            - key: {{ . }}
131              path: {{ . }}
132           {{ end }}
133       restartPolicy: OnFailure
134       imagePullSecrets:
135       - name: "{{ include "common.namespace" . }}-docker-registry-key"
136 {{ end }}