c18a2016b61cb7181f07a798beed5e5781bb21ae
[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         - --service-name
46         - {{ index .Values "mariadb-galera" "service" "name" }}
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         resources:
61           limits:
62             cpu: "100m"
63             memory: "500Mi"
64           requests:
65             cpu: "3m"
66             memory: "20Mi"
67       {{ if .Values.config.msb_enabled }}
68       {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
69       {{ end }}
70       - command:
71         - /bin/sh
72         - -c
73         - chown -R 1000:1000 /service/modeling/etsicatalog/static
74         image: {{ include "repositoryGenerator.image.busybox" . }}
75         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
76         name: {{ include "common.name" . }}-init
77         volumeMounts:
78         - name: {{ include "common.fullname" . }}-etsicatalog
79           mountPath: /service/modeling/etsicatalog/static
80       containers:
81         - name: {{ include "common.name" . }}
82           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
83           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
84           ports:
85           - containerPort: {{ .Values.service.internalPort }}
86           # disable liveness probe when breakpoints set in debugger
87           # so K8s doesn't restart unresponsive container
88           {{ if .Values.liveness.enabled }}
89           livenessProbe:
90             tcpSocket:
91               port: {{ .Values.service.internalPort }}
92             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
93             periodSeconds: {{ .Values.liveness.periodSeconds }}
94           {{ end }}
95           readinessProbe:
96             tcpSocket:
97               port: {{ .Values.service.internalPort }}
98             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
99             periodSeconds: {{ .Values.readiness.periodSeconds }}
100           env:
101           {{- if and (include "common.needTLS" .) (eq .Values.config.ssl_enabled true) }}
102           - name: SSL_ENABLED
103             value: "true"
104           {{- else }}
105           - name: SSL_ENABLED
106             value: "false"
107           {{- end }}
108           - name: MSB_ENABLED
109             value: "{{ .Values.config.msb_enabled }}"
110           {{- if (include "common.needTLS" .) }}
111           - name: MSB_ADDR
112             value: "{{ .Values.config.msbProtocol }}s://{{ .Values.config.msbServiceName }}:{{ .Values.config.msbPort }}"
113           - name: SDC_ADDR
114             value: "{{ .Values.config.sdcProtocol }}s://{{ .Values.config.sdcServiceName }}:{{ .Values.config.sdcPort }}"
115           {{- else }}
116           - name: MSB_ADDR
117             value: "{{ .Values.config.msbProtocol }}://{{ .Values.config.msbServiceName }}:{{ .Values.config.msbPlainPort }}"
118           - name: SDC_ADDR
119             value: "{{ .Values.config.sdcProtocol }}://{{ .Values.config.sdcServiceName }}:{{ .Values.config.sdcPlainPort }}"
120           {{- end }}
121           - name: DMAAP_ENABLED
122             value: "{{ .Values.config.dmaap_enabled }}"
123           - name: DMAAP_ADDR
124             value: "{{ .Values.config.dmaapProtocol }}{{ (eq "true" (include "common.needTLS" .)) | ternary "s" "" }}://{{ .Values.config.dmaapServiceName }}:{{ .Values.config.dmaapPort }}"
125           - name: DB_IP
126             value: "{{ include "common.mariadbService" . }}"
127           - name: DB_PORT
128             value: "{{ include "common.mariadbPort" . }}"
129           - name: DB_USER
130             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "login") | indent 12 }}
131           - name: DB_PASSWD
132             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "password") | indent 12 }}
133           volumeMounts:
134           - name: {{ include "common.fullname" . }}-etsicatalog
135             mountPath: /service/modeling/etsicatalog/static
136           - name: {{ include "common.fullname" . }}-localtime
137             mountPath: /etc/localtime
138             readOnly: true
139           - name: {{ include "common.fullname" . }}-logs
140             mountPath: {{ .Values.log.path }}
141           - name: {{ include "common.fullname" . }}-logconfig
142             mountPath: /opt/modeling/etsicatalog/config/log.yml
143             subPath: log.yml
144           resources: {{ include "common.resources" . | nindent 12 }}
145         {{- if .Values.nodeSelector }}
146         nodeSelector:
147 {{ toYaml .Values.nodeSelector | indent 10 }}
148         {{- end -}}
149         {{- if .Values.affinity }}
150         affinity:
151 {{ toYaml .Values.affinity | indent 10 }}
152         {{- end }}
153
154         # side car containers
155       {{ include "common.log.sidecar" . | nindent 8 }}
156       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
157       volumes:
158         - name: {{ include "common.fullname" . }}-etsicatalog
159         {{- if .Values.persistence.enabled }}
160           persistentVolumeClaim:
161             claimName: {{ include "common.fullname" . }}
162         {{- else }}
163           emptyDir: {}
164         {{- end }}
165         - name: {{ include "common.fullname" . }}-localtime
166           hostPath:
167             path: /etc/localtime
168         - name:  {{ include "common.fullname" . }}-logs
169           emptyDir: {}
170         - name: {{ include "common.fullname" . }}-logconfig
171           configMap:
172             name : {{ include "common.fullname" . }}-logging-configmap
173
174         {{ include "common.log.volumes" . | nindent 8 }}
175       {{- include "common.imagePullSecrets" . | nindent 6 }}