cf7a309ef083e118a2873373cfceaaf0f48226df
[oom.git] / kubernetes / aai / components / aai-sparky-be / templates / deployment.yaml
1 {{/*
2 # Copyright (c) 2017 Amdocs, Bell Canada
3 # Modifications Copyright (c) 2018 AT&T
4 # Modifications Copyright (c) 2020 Nokia
5 # Modifications Copyright © 2023 Nordix Foundation
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 */}}
19
20 apiVersion: apps/v1
21 kind: Deployment
22 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
23 spec:
24   selector: {{- include "common.selectors" . | nindent 4 }}
25   replicas: {{ .Values.replicaCount }}
26   strategy:
27     type: {{ .Values.updateStrategy.type }}
28     {{- if (eq "RollingUpdate" .Values.updateStrategy.type) }}
29     rollingUpdate:
30       maxUnavailable: {{ .Values.updateStrategy.maxUnavailable }}
31       maxSurge: {{ .Values.updateStrategy.maxSurge }}
32     {{- end }}
33   template:
34     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
35     spec:
36       initContainers:
37       - command:
38         - /app/ready.py
39         args:
40         - --container-name
41         - aai
42         env:
43         - name: NAMESPACE
44           valueFrom:
45             fieldRef:
46               apiVersion: v1
47               fieldPath: metadata.namespace
48         image: {{ include "repositoryGenerator.image.readiness" . }}
49         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50         name: {{ include "common.name" . }}-readiness
51       containers:
52       - name: {{ include "common.name" . }}
53         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
54         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55         command:
56         - sh
57         args:
58         - -c
59         - |
60           echo "*** actual launch of AAI Sparky BE"
61           /opt/app/sparky/bin/start.sh
62         volumeMounts:
63         - mountPath: /etc/localtime
64           name: localtime
65           readOnly: true
66         - mountPath: {{ .Values.log.path }}
67           name: logs
68         - mountPath:  /opt/app/sparky/config/application.properties
69           name: config
70           subPath: application.properties
71         - mountPath:  /opt/app/sparky/config/application-resources.properties
72           name: config
73           subPath: application-resources.properties
74         - mountPath:  /opt/app/sparky/config/application-ssl.properties
75           name: config
76           subPath: application-ssl.properties
77         - mountPath:  /opt/app/sparky/config/application-oxm-default.properties
78           name: config
79           subPath: application-oxm-default.properties
80         - mountPath:  /opt/app/sparky/config/application-oxm-override.properties
81           name: config
82           subPath: application-oxm-override.properties
83         - mountPath:  /opt/app/sparky/config/application-oxm-schema-prod.properties
84           name: config
85           subPath: application-oxm-schema-prod.properties
86         - mountPath:  /opt/app/sparky/config/roles.config
87           name: config
88           subPath: roles.config
89         - mountPath:  /opt/app/sparky/config/users.config
90           name: config
91           subPath: users.config
92         - mountPath:  /opt/app/sparky/config/logging/logback.xml
93           name: config
94           subPath: logback.xml
95         ports: {{ include "common.containerPorts" . | nindent 10  }}
96         # disable liveness probe when breakpoints set in debugger
97         # so K8s doesn't restart unresponsive container
98         {{- if eq .Values.liveness.enabled true }}
99         livenessProbe:
100           tcpSocket:
101             port: {{ .Values.service.internalPort }}
102           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
103           periodSeconds: {{ .Values.liveness.periodSeconds }}
104         {{ end -}}
105         readinessProbe:
106           tcpSocket:
107             port: {{ .Values.service.internalPort }}
108           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
109           periodSeconds: {{ .Values.readiness.periodSeconds }}
110         resources: {{ include "common.resources" . | nindent 10 }}
111       {{- if .Values.nodeSelector }}
112       nodeSelector:
113 {{ toYaml .Values.nodeSelector | indent 8 }}
114       {{- end -}}
115       {{- if .Values.affinity }}
116       affinity:
117 {{ toYaml .Values.affinity | indent 8 }}
118       {{- end }}
119
120       # side car containers
121       {{ include "common.log.sidecar" . | nindent 6 }}
122       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
123       volumes:
124       - name: localtime
125         hostPath:
126           path: /etc/localtime
127       - name: config
128         configMap:
129           name: {{ include "common.fullname" . }}
130       - name: logs
131         emptyDir: {}
132         {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix .)) | nindent 6 }}
133       - name: modeldir
134         emptyDir: {}
135       restartPolicy: {{ .Values.global.restartPolicy | default .Values.restartPolicy }}
136       imagePullSecrets:
137       - name: "{{ include "common.namespace" . }}-docker-registry-key"