9e1dcdd0849b6e86309c0d5498a1f4609a256ee6
[oom.git] / kubernetes / modeling / components / modeling-etsicatalog / templates / deployment.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16
17 apiVersion: apps/v1
18 kind: Deployment
19 metadata:
20   name: {{ include "common.fullname" . }}
21   namespace: {{ include "common.namespace" . }}
22   labels:
23     app: {{ include "common.name" . }}
24     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
25     release: {{ include "common.release" . }}
26     heritage: {{ .Release.Service }}
27 spec:
28   selector:
29     matchLabels:
30       app: {{ include "common.name" . }}
31   replicas: {{ .Values.replicaCount }}
32   template:
33     metadata:
34       labels:
35         app: {{ include "common.name" . }}
36         release: {{ include "common.release" . }}
37       annotations:
38         sidecar.istio.io/inject: "{{.Values.istioSidecar}}"
39     spec:
40       initContainers:
41       - command:
42         - /app/ready.py
43         args:
44 {{- if .Values.global.mariadbGalera.localCluster }}
45         - --app-name
46         - {{ index .Values "mariadb-galera" "nameOverride" }}
47 {{- else }}
48         - --job-name
49         - {{ include "common.release" . }}-etsicatalog-db-config-job
50 {{- end }}
51         env:
52         - name: NAMESPACE
53           valueFrom:
54             fieldRef:
55               apiVersion: v1
56               fieldPath: metadata.namespace
57         image: {{ include "repositoryGenerator.image.readiness" . }}
58         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59         name: {{ include "common.name" . }}-job-readiness
60       {{ if .Values.config.msb_enabled }}
61       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for.msb ) | indent 6 | trim }}
62       {{ end }}
63       - command:
64         - /bin/sh
65         - -c
66         - chown -R 1000:1000 /service/modeling/etsicatalog/static
67         image: {{ include "repositoryGenerator.image.busybox" . }}
68         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
69         name: {{ include "common.name" . }}-init
70         volumeMounts:
71         - name: {{ include "common.fullname" . }}-etsicatalog
72           mountPath: /service/modeling/etsicatalog/static
73       containers:
74         - name: {{ include "common.name" . }}
75           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
76           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77           ports:
78           - containerPort: {{ .Values.service.internalPort }}
79           # disable liveness probe when breakpoints set in debugger
80           # so K8s doesn't restart unresponsive container
81           {{ if .Values.liveness.enabled }}
82           livenessProbe:
83             tcpSocket:
84               port: {{ .Values.service.internalPort }}
85             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
86             periodSeconds: {{ .Values.liveness.periodSeconds }}
87           {{ end }}
88           readinessProbe:
89             tcpSocket:
90               port: {{ .Values.service.internalPort }}
91             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
92             periodSeconds: {{ .Values.readiness.periodSeconds }}
93           env:
94           {{- if and (include "common.needTLS" .) (eq .Values.config.ssl_enabled true) }}
95           - name: SSL_ENABLED
96             value: "true"
97           {{- else }}
98           - name: SSL_ENABLED
99             value: "false"
100           {{- end }}
101           - name: MSB_ENABLED
102             value: "{{ .Values.config.msb_enabled }}"
103           {{- if (include "common.needTLS" .) }}
104           - name: MSB_ADDR
105             value: "{{ .Values.config.msbProtocol }}s://{{ .Values.config.msbServiceName }}:{{ .Values.config.msbPort }}"
106           - name: SDC_ADDR
107             value: "{{ .Values.config.sdcProtocol }}s://{{ .Values.config.sdcServiceName }}:{{ .Values.config.sdcPort }}"
108           {{- else }}
109           - name: MSB_ADDR
110             value: "{{ .Values.config.msbProtocol }}://{{ .Values.config.msbServiceName }}:{{ .Values.config.msbPlainPort }}"
111           - name: SDC_ADDR
112             value: "{{ .Values.config.sdcProtocol }}://{{ .Values.config.sdcServiceName }}:{{ .Values.config.sdcPlainPort }}"
113           {{- end }}
114           - name: DMAAP_ENABLED
115             value: "{{ .Values.config.dmaap_enabled }}"
116           - name: DMAAP_ADDR
117             value: "{{ .Values.config.dmaapProtocol }}{{ (eq "true" (include "common.needTLS" .)) | ternary "s" "" }}://{{ .Values.config.dmaapServiceName }}:{{ .Values.config.dmaapPort }}"
118           - name: DB_IP
119             value: "{{ include "common.mariadbService" . }}"
120           - name: DB_PORT
121             value: "{{ include "common.mariadbPort" . }}"
122           - name: DB_USER
123             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "login") | indent 12 }}
124           - name: DB_PASSWD
125             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "password") | indent 12 }}
126           volumeMounts:
127           - name: {{ include "common.fullname" . }}-etsicatalog
128             mountPath: /service/modeling/etsicatalog/static
129           - name: {{ include "common.fullname" . }}-localtime
130             mountPath: /etc/localtime
131             readOnly: true
132           - name: {{ include "common.fullname" . }}-logs
133             mountPath: {{ .Values.log.path }}
134           - name: {{ include "common.fullname" . }}-logconfig
135             mountPath: /opt/modeling/etsicatalog/config/log.yml
136             subPath: log.yml
137           resources: {{ include "common.resources" . | nindent 12 }}
138         {{- if .Values.nodeSelector }}
139         nodeSelector:
140 {{ toYaml .Values.nodeSelector | indent 10 }}
141         {{- end -}}
142         {{- if .Values.affinity }}
143         affinity:
144 {{ toYaml .Values.affinity | indent 10 }}
145         {{- end }}
146
147         # side car containers
148       {{ include "common.log.sidecar" . | nindent 8 }}
149       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
150       volumes:
151         - name: {{ include "common.fullname" . }}-etsicatalog
152         {{- if .Values.persistence.enabled }}
153           persistentVolumeClaim:
154             claimName: {{ include "common.fullname" . }}
155         {{- else }}
156           emptyDir: {}
157         {{- end }}
158         - name: {{ include "common.fullname" . }}-localtime
159           hostPath:
160             path: /etc/localtime
161         - name:  {{ include "common.fullname" . }}-logs
162           emptyDir: {}
163         - name: {{ include "common.fullname" . }}-logconfig
164           configMap:
165             name : {{ include "common.fullname" . }}-logging-configmap
166
167         {{ include "common.log.volumes" . | nindent 8 }}
168       imagePullSecrets:
169       - name: "{{ include "common.namespace" . }}-docker-registry-key"