AAI Rolling upgrade using helm hooks
[oom.git] / kubernetes / aai / charts / aai-graphadmin / templates / deployment.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 apiVersion: extensions/v1beta1
20 kind: Deployment
21 metadata:
22   name: {{ include "common.fullname" . }}
23   namespace: {{ include "common.namespace" . }}
24   labels:
25     app: {{ include "common.name" . }}
26     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27     release: {{ .Release.Name }}
28     heritage: {{ .Release.Service }}
29 spec:
30   replicas: {{ .Values.replicaCount }}
31   selector:
32     matchLabels:
33       app: {{ include "common.name" . }}
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ .Release.Name }}
39       name: {{ include "common.name" . }}
40       annotations:
41         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
42     spec:
43       hostname: aai-graphadmin
44     {{ if .Values.global.initContainers.enabled }}
45       initContainers:
46       - command:
47       {{ if .Values.global.jobs.migration.enabled }}
48         - /root/job_complete.py
49         args:
50         - --job-name
51         - {{ .Release.Name }}-aai-graphadmin-migration
52       {{  else if .Values.global.jobs.createSchema.enabled  }}
53         - /root/job_complete.py
54         args:
55         - --job-name
56         - {{ .Release.Name }}-aai-graphadmin-create-db-schema
57       {{  else }}
58         - /root/ready.py
59         args:
60         - --container-name
61         {{- if .Values.global.cassandra.localCluster }}
62         - aai-cassandra
63         {{- else }}
64         - cassandra
65         {{- end }}
66         - --container-name
67         - aai-schema-service
68       {{  end  }}
69         env:
70         - name: NAMESPACE
71           valueFrom:
72             fieldRef:
73               apiVersion: v1
74               fieldPath: metadata.namespace
75         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
76         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         name: {{ include "common.name" . }}-readiness
78       {{  end  }}
79       containers:
80       - name: {{ include "common.name" . }}
81         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
82         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
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-RES
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/etc/auth/realm.properties
110           name: {{ include "common.fullname" . }}-config
111           subPath: realm.properties
112         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
113           name: {{ include "common.fullname" . }}-config
114           subPath: application.properties
115           {{ $global := . }}
116           {{ range $job := .Values.global.config.auth.files }}
117         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/{{ . }}
118           name: {{ include "common.fullname" $global }}-auth-truststore-sec
119           subPath: {{ . }}
120           {{ end }}
121         ports:
122         - containerPort: {{ .Values.service.internalPort }}
123         - containerPort: {{ .Values.service.internalPort2 }}
124         # disable liveness probe when breakpoints set in debugger
125         # so K8s doesn't restart unresponsive container
126         {{ if .Values.liveness.enabled }}
127         livenessProbe:
128           tcpSocket:
129             port: {{ .Values.service.internalPort }}
130           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
131           periodSeconds: {{ .Values.liveness.periodSeconds }}
132         {{ end }}
133         readinessProbe:
134           tcpSocket:
135             port: {{ .Values.service.internalPort }}
136           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
137           periodSeconds: {{ .Values.readiness.periodSeconds }}
138         resources:
139 {{ include "common.resources" . }}
140       {{- if .Values.nodeSelector }}
141       nodeSelector:
142 {{ toYaml .Values.nodeSelector | indent 8 }}
143       {{- end -}}
144       {{- if .Values.affinity }}
145       affinity:
146 {{ toYaml .Values.affinity | indent 8 }}
147       {{- end }}
148
149       # side car containers
150       - name: filebeat-onap
151         image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
152         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
153         volumeMounts:
154         - mountPath: /usr/share/filebeat/filebeat.yml
155           subPath: filebeat.yml
156           name: filebeat-conf
157         - mountPath: /var/log/onap
158           name: {{ include "common.fullname" . }}-logs
159         - mountPath: /usr/share/filebeat/data
160           name: {{ include "common.fullname" . }}-filebeat
161
162       volumes:
163       - name: localtime
164         hostPath:
165           path: /etc/localtime
166       - name: filebeat-conf
167         configMap:
168           name: aai-filebeat
169       - name: {{ include "common.fullname" . }}-logs
170         emptyDir: {}
171       - name: {{ include "common.fullname" . }}-filebeat
172         emptyDir: {}
173       - name: {{ include "common.fullname" . }}-config
174         configMap:
175          name: {{ include "common.fullname" . }}-configmap
176       - name: {{ include "common.fullname" . }}-auth-truststore-sec
177         secret:
178          secretName: aai-common-truststore
179          items:
180           {{ range $job := .Values.global.config.auth.files }}
181            - key: {{ . }}
182              path: {{ . }}
183           {{ end }}
184       restartPolicy: {{ .Values.restartPolicy }}
185       imagePullSecrets:
186       - name: "{{ include "common.namespace" . }}-docker-registry-key"