[SO] 16.0.2 release
[oom.git] / kubernetes / aai / components / aai-traversal / templates / deployment.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 # Modifications Copyright © 2018 AT&T
4 # Modifications Copyright © 2020 Nokia, Orange
5 # Modifications Copyright © 2021 Orange
6 # Modifications Copyright © 2023 Nordix Foundation
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #       http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 */}}
20
21 apiVersion: apps/v1
22 kind: Deployment
23 metadata: {{- include "common.resourceMetadata" (dict "annotations" .Values.annotations "dot" .) | nindent 2 }}
24 spec:
25   {{- if or .Values.config.debug.enabled .Values.config.profiling.enabled }}
26   replicas: 1
27   {{- else }}
28   {{- if not .Values.autoscaling.enabled }}
29   replicas: {{ .Values.replicaCount }}
30   {{- end }}
31   {{- end }}
32   revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
33   minReadySeconds: {{ .Values.minReadySeconds }}
34   strategy:
35     type: {{ .Values.updateStrategy.type }}
36     rollingUpdate:
37       maxUnavailable: {{ .Values.updateStrategy.maxUnavailable }}
38       maxSurge: {{ .Values.updateStrategy.maxSurge }}
39   selector:
40     matchLabels:
41       app: {{ include "common.name" . }}
42   template:
43     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
44     spec:
45       hostname: aai-traversal
46       terminationGracePeriodSeconds: {{ .Values.service.terminationGracePeriodSeconds }}
47       initContainers:
48       {{- if .Values.global.jobs.migration.enabled }}
49       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_migration) | nindent 8 }}
50       {{- else if .Values.global.jobs.createSchema.enabled  }}
51       {{ include "aai.waitForSchemaCreation" . | nindent 6 }}
52       {{- else }}
53       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_cassandra) | nindent 8 }}
54       {{- end }}
55       {{ include "common.podSecurityContext" . | indent 6 | trim }}
56       containers:
57       - name: {{ include "common.name" . }}
58         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
59         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
60         {{ include "common.containerSecurityContext" . | indent 8 | trim }}
61         env:
62         {{- if .Values.config.env }}
63         {{- range $key,$value := .Values.config.env }}
64         - name: {{ $key | upper | quote}}
65           value: {{ $value | quote}}
66         {{- end }}
67         {{- end }}
68         {{- if eq .Values.flavor "small" }}
69         - name: MAX_HEAP_SIZE
70           value: {{ .Values.small.maxHeapSize | quote }}
71         {{- else if eq .Values.flavor "large" }}
72         - name: MAX_HEAP_SIZE
73           value: {{ .Values.large.maxHeapSize | quote }}
74         {{- end }}
75         {{- if .Values.config.profiling.enabled }}
76         - name: PRE_JVM_ARGS
77           value: '{{ join " " .Values.config.profiling.args }}'
78         {{- end }}
79         {{- if .Values.config.debug.enabled }}
80         - name: POST_JVM_ARGS
81           value: {{ .Values.config.debug.args | quote }}
82         {{- end }}
83         - name: DISABLE_UPDATE_QUERY
84           value: {{ .Values.config.disableUpdateQuery | quote }}
85         - name: INTERNAL_PORT_1
86           value: {{ .Values.service.traversalPort | quote }}
87         - name: INTERNAL_PORT_2
88           value: {{ .Values.service.debugPort | quote }}
89         - name: INTERNAL_PORT_3
90           value: {{ .Values.service.metricsPort | quote }}
91         - name: BOOTSTRAP_SERVERS
92           value: {{ include "common.release" . }}-strimzi-kafka-bootstrap:9092
93         - name: JAAS_CONFIG
94           valueFrom:
95             secretKeyRef:
96               name: {{ include "common.release" . }}-{{ .Values.global.aaiTravKafkaUser }}
97               key: sasl.jaas.config
98         volumeMounts:
99         - mountPath: /opt/app/aai-traversal/resources/etc/appprops/janusgraph-realtime.properties
100           name: {{ include "common.fullname" . }}-config
101           subPath: janusgraph-realtime.properties
102         - mountPath: /opt/app/aai-traversal/resources/etc/appprops/aaiconfig.properties
103           name: {{ include "common.fullname" . }}-config
104           subPath: aaiconfig.properties
105         - mountPath: /opt/aai/logroot/AAI-GQ
106           name: logs
107         - mountPath: /opt/aai/logroot/AAI-GQ/misc
108           name: {{ include "common.fullname" . }}-logs-misc
109         - mountPath: /opt/app/aai-traversal/resources/logback.xml
110           name: {{ include "common.fullname" . }}-config
111           subPath: logback.xml
112         - mountPath: /opt/app/aai-traversal/resources/application.properties
113           name: {{ include "common.fullname" . }}-config
114           subPath: application.properties
115         - mountPath: /tmp
116           name: tmp
117         ports:
118         - containerPort: {{ .Values.service.traversalPort }}
119           name: {{ .Values.service.traversalPortName }}
120         {{- if .Values.config.debug.enabled }}
121         - containerPort: {{ .Values.service.debugPort }}
122           name: {{ .Values.service.debugPortName }}
123         {{- end }}
124         - containerPort: {{ .Values.service.metricsPort }}
125           name: {{ .Values.service.metricsPortName }}
126         {{- if .Values.config.profiling.enabled }}
127         - containerPort: {{ .Values.service.profilingPort }}
128           name: {{ .Values.service.profilingPortName }}
129         {{- end }}
130         lifecycle:
131           # wait for active requests (long-running tasks) to be finished
132           # Before the SIGTERM is invoked, Kubernetes exposes a preStop hook in the Pod.
133           preStop:
134             exec:
135               command:
136                 - sh
137                 - -c
138                 - |
139                   while (netstat -an | grep ESTABLISHED | grep -e $INTERNAL_PORT_1)
140                   do sleep 3
141                   done
142         # disable liveness probe when
143         # debugging.enable=true or profiling.enabled=true
144         {{- if and .Values.liveness.enabled (not (or .Values.config.debug.enabled .Values.config.profiling.enabled)) }}
145         livenessProbe:
146           httpGet:
147             port: {{ .Values.service.metricsPort }}
148             path: {{ .Values.liveness.path }}
149           {{- if .Values.liveness.initialDelaySeconds }}
150           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
151           {{- end }}
152           periodSeconds: {{ .Values.liveness.periodSeconds }}
153         {{- end }}
154         readinessProbe:
155           httpGet:
156             port: {{ .Values.service.metricsPort }}
157             path: {{ .Values.readiness.path }}
158           {{- if .Values.readiness.initialDelaySeconds }}
159           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
160           {{- end }}
161           periodSeconds: {{ .Values.readiness.periodSeconds }}
162         resources: {{ include "common.resources" . | nindent 10 }}
163       {{- if .Values.nodeSelector }}
164       nodeSelector: {{ toYaml .Values.nodeSelector | indent 8 }}
165       {{- end }}
166       {{- if .Values.affinity }}
167       affinity: {{ toYaml .Values.affinity | indent 8 }}
168       {{- end }}
169
170       # side car containers
171       {{ include "common.log.sidecar" . | nindent 6 }}
172       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
173       volumes:
174       - name: logs
175         emptyDir:
176           sizeLimit: {{ .Values.volumes.logSizeLimit }}
177       - name: tmp
178         emptyDir:
179           sizeLimit: {{ .Values.volumes.tmpSizeLimit }}
180       - name: {{ include "common.fullname" . }}-logs-misc
181         emptyDir:
182           sizeLimit: {{ .Values.volumes.logmiscSizeLimit }}
183       {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix .)) | nindent 6 }}
184       - name: {{ include "common.fullname" . }}-config
185         configMap:
186           name: {{ include "common.fullname" . }}
187       restartPolicy: {{ .Values.global.restartPolicy | default .Values.restartPolicy }}
188       {{- include "common.imagePullSecrets" . | nindent 6 }}