Merge "[AAI] Service Mesh compatibility"
[oom.git] / kubernetes / aai / components / aai-graphadmin / templates / deployment.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 Orange Intellectual Property. All rights reserved.
9 # ================================================================================
10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at
13 #
14 #    http://www.apache.org/licenses/LICENSE-2.0
15 #
16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and
20 # limitations under the License.
21 # ============LICENSE_END=========================================================
22 */}}
23 apiVersion: apps/v1
24 kind: Deployment
25 metadata:
26   name: {{ include "common.fullname" . }}
27   namespace: {{ include "common.namespace" . }}
28   labels:
29     app: {{ include "common.name" . }}
30     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
31     release: {{ include "common.release" . }}
32     heritage: {{ .Release.Service }}
33 spec:
34   replicas: {{ .Values.replicaCount }}
35   minReadySeconds: {{ .Values.minReadySeconds }}
36   strategy:
37     type: {{ .Values.updateStrategy.type }}
38     rollingUpdate:
39       maxUnavailable: {{ .Values.updateStrategy.maxUnavailable }}
40       maxSurge: {{ .Values.updateStrategy.maxSurge }}
41   selector:
42     matchLabels:
43       app: {{ include "common.name" . }}
44   template:
45     metadata:
46       labels:
47         app: {{ include "common.name" . }}
48         release: {{ include "common.release" . }}
49       name: {{ include "common.name" . }}
50       annotations:
51         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
52     spec:
53       hostname: aai-graphadmin
54       terminationGracePeriodSeconds: {{ .Values.service.terminationGracePeriodSeconds }}
55     {{ if .Values.global.initContainers.enabled }}
56       initContainers:
57       - command:
58       {{ if .Values.global.jobs.migration.enabled }}
59         - /app/ready.py
60         args:
61         - --job-name
62         - {{ include "common.release" . }}-aai-graphadmin-migration
63       {{  else if .Values.global.jobs.createSchema.enabled  }}
64         - /app/ready.py
65         args:
66         - --job-name
67         - {{ include "common.release" . }}-aai-graphadmin-create-db-schema
68       {{  else }}
69         - /app/ready.py
70         args:
71         - --container-name
72         {{- if .Values.global.cassandra.localCluster }}
73         - aai-cassandra
74         {{- else }}
75         - cassandra
76         {{- end }}
77         - --container-name
78         - aai-schema-service
79       {{  end  }}
80         env:
81         - name: NAMESPACE
82           valueFrom:
83             fieldRef:
84               apiVersion: v1
85               fieldPath: metadata.namespace
86         image: {{ include "repositoryGenerator.image.readiness" . }}
87         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
88         name: {{ include "common.name" . }}-readiness
89       {{  end  }}
90       containers:
91       - name: {{ include "common.name" . }}
92         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
93         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
94         env:
95         - name: LOCAL_USER_ID
96           value: {{ .Values.global.config.userId | quote }}
97         - name: LOCAL_GROUP_ID
98           value: {{ .Values.global.config.groupId | quote }}
99         - name: INTERNAL_PORT_1
100           value: {{ .Values.service.internalPort | quote }}
101         - name: INTERNAL_PORT_2
102           value: {{ .Values.service.internalPort2 | quote }}
103         volumeMounts:
104         - mountPath: /etc/localtime
105           name: localtime
106           readOnly: true
107         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
108           name: {{ include "common.fullname" . }}-config
109           subPath: janusgraph-realtime.properties
110         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
111           name: {{ include "common.fullname" . }}-config
112           subPath: janusgraph-cached.properties
113         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
114           name: {{ include "common.fullname" . }}-config
115           subPath: aaiconfig.properties
116         - mountPath: /opt/aai/logroot/AAI-RES
117           name: {{ include "common.fullname" . }}-logs
118         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
119           name: {{ include "common.fullname" . }}-config
120           subPath: logback.xml
121         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
122           name: {{ include "common.fullname" . }}-config
123           subPath: localhost-access-logback.xml
124         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/realm.properties
125           name: {{ include "common.fullname" . }}-config
126           subPath: realm.properties
127         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
128           name: {{ include "common.fullname" . }}-config
129           subPath: application.properties
130           {{ $global := . }}
131           {{ range $job := .Values.global.config.auth.files }}
132         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/{{ . }}
133           name: {{ include "common.fullname" $global }}-auth-truststore-sec
134           subPath: {{ . }}
135           {{ end }}
136         ports:
137         - containerPort: {{ .Values.service.internalPort }}
138         - containerPort: {{ .Values.service.internalPort2 }}
139         lifecycle:
140           # wait for active requests (long-running tasks) to be finished
141           # Before the SIGTERM is invoked, Kubernetes exposes a preStop hook in the Pod.
142           preStop:
143             exec:
144               command:
145                 - sh
146                 - -c
147                 - |
148                   while (netstat -an | grep ESTABLISHED | grep -e $INTERNAL_PORT_1 -e $INTERNAL_PORT_2)
149                   do sleep 10
150                   done
151         # disable liveness probe when breakpoints set in debugger
152         # so K8s doesn't restart unresponsive container
153         {{ if .Values.liveness.enabled }}
154         livenessProbe:
155           tcpSocket:
156             port: {{ .Values.service.internalPort }}
157           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
158           periodSeconds: {{ .Values.liveness.periodSeconds }}
159         {{ end }}
160         readinessProbe:
161           tcpSocket:
162             port: {{ .Values.service.internalPort }}
163           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
164           periodSeconds: {{ .Values.readiness.periodSeconds }}
165         resources:
166 {{ include "common.resources" . }}
167       {{- if .Values.nodeSelector }}
168       nodeSelector:
169 {{ toYaml .Values.nodeSelector | indent 8 }}
170       {{- end -}}
171       {{- if .Values.affinity }}
172       affinity:
173 {{ toYaml .Values.affinity | indent 8 }}
174       {{- end }}
175
176       # side car containers
177       - name: filebeat-onap
178         image: {{ include "repositoryGenerator.image.logging" . }}
179         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
180         volumeMounts:
181         - mountPath: /usr/share/filebeat/filebeat.yml
182           subPath: filebeat.yml
183           name: filebeat-conf
184         - mountPath: /var/log/onap
185           name: {{ include "common.fullname" . }}-logs
186         - mountPath: /usr/share/filebeat/data
187           name: {{ include "common.fullname" . }}-filebeat
188       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
189       volumes:
190       - name: localtime
191         hostPath:
192           path: /etc/localtime
193       - name: filebeat-conf
194         configMap:
195           name: aai-filebeat
196       - name: {{ include "common.fullname" . }}-logs
197         emptyDir: {}
198       - name: {{ include "common.fullname" . }}-filebeat
199         emptyDir: {}
200       - name: {{ include "common.fullname" . }}-config
201         configMap:
202           name: {{ include "common.fullname" . }}-configmap
203       - name: {{ include "common.fullname" . }}-auth-truststore-sec
204         secret:
205           secretName: aai-common-truststore
206           items:
207             {{ range $job := .Values.global.config.auth.files }}
208             - key: {{ . }}
209               path: {{ . }}
210             {{ end }}
211       restartPolicy: {{ .Values.restartPolicy }}
212       imagePullSecrets:
213       - name: {{ include "common.namespace" . }}-docker-registry-key