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