bdcd0501ef0a833b50de413f2679ac6738fa12ac
[oom.git] / kubernetes / modeling / charts / 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         - -j
45         - "{{ include "common.release" . }}-{{ include "common.name" . }}-config-job"
46         env:
47         - name: NAMESPACE
48           valueFrom:
49             fieldRef:
50               apiVersion: v1
51               fieldPath: metadata.namespace
52         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
53         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
54         name: {{ include "common.name" . }}-job-readiness
55       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for.msb ) | indent 6 | trim }}
56       - command:
57         - /bin/sh
58         - -c
59         - chown -R 1000:1000 /service/modeling/etsicatalog/static
60         image: "{{ include "common.repository" . }}/{{ .Values.initImage }}"
61         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
62         name: {{ include "common.name" . }}-init
63         volumeMounts:
64         - name: {{ include "common.fullname" . }}-etsicatalog
65           mountPath: /service/modeling/etsicatalog/static
66       containers:
67         - name: {{ include "common.name" . }}
68           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
69           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
70           ports:
71           - containerPort: {{ .Values.service.internalPort }}
72           # disable liveness probe when breakpoints set in debugger
73           # so K8s doesn't restart unresponsive container
74           {{ if .Values.liveness.enabled }}
75           livenessProbe:
76             tcpSocket:
77               port: {{ .Values.service.internalPort }}
78             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
79             periodSeconds: {{ .Values.liveness.periodSeconds }}
80           {{ end }}
81           readinessProbe:
82             tcpSocket:
83               port: {{ .Values.service.internalPort }}
84             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
85             periodSeconds: {{ .Values.readiness.periodSeconds }}
86           env:
87           - name: MSB_ADDR
88             value: "{{ .Values.config.msbProtocol }}://{{ .Values.config.msbServiceName }}:{{ .Values.config.msbPort }}"
89           - name: SSL_ENABLED
90             value: "{{ .Values.config.ssl_enabled }}"
91           - name: MSB_ENABLED
92             value: "{{ .Values.config.msb_enabled }}"
93           - name: DB_IP
94             value: "{{ include "common.mariadbService" . }}"
95           - name: DB_PORT
96             value: "{{ include "common.mariadbPort" . }}"
97           - name: DB_USER
98             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "login") | indent 12 }}
99           - name: DB_PASSWD
100             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "password") | indent 12 }}
101           volumeMounts:
102           - name: {{ include "common.fullname" . }}-etsicatalog
103             mountPath: /service/modeling/etsicatalog/static
104           - name: {{ include "common.fullname" . }}-localtime
105             mountPath: /etc/localtime
106             readOnly: true
107           - name: {{ include "common.fullname" . }}-logs
108             mountPath: /var/log/onap
109           - name: {{ include "common.fullname" . }}-logconfig
110             mountPath: /opt/modeling/etsicatalog/config/log.yml
111             subPath: log.yml
112           resources:
113 {{ include "common.resources" . | indent 12 }}
114         {{- if .Values.nodeSelector }}
115         nodeSelector:
116 {{ toYaml .Values.nodeSelector | indent 10 }}
117         {{- end -}}
118         {{- if .Values.affinity }}
119         affinity:
120 {{ toYaml .Values.affinity | indent 10 }}
121         {{- end }}
122
123         # side car containers
124         - name: {{ include "common.name" . }}-filebeat-onap
125           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
126           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
127           volumeMounts:
128           - name: {{ include "common.fullname" . }}-filebeat-conf
129             mountPath: /usr/share/filebeat/filebeat.yml
130             subPath: filebeat.yml
131           - name: {{ include "common.fullname" . }}-logs
132             mountPath: /var/log/onap
133           - name: {{ include "common.fullname" . }}-data-filebeat
134             mountPath: /usr/share/filebeat/data
135
136       volumes:
137         - name: {{ include "common.fullname" . }}-etsicatalog
138         {{- if .Values.persistence.enabled }}
139           persistentVolumeClaim:
140             claimName: {{ include "common.fullname" . }}
141         {{- else }}
142           emptyDir: {}
143         {{- end }}
144         - name: {{ include "common.fullname" . }}-localtime
145           hostPath:
146             path: /etc/localtime
147         - name:  {{ include "common.fullname" . }}-logs
148           emptyDir: {}
149         - name: {{ include "common.fullname" . }}-logconfig
150           configMap:
151             name : {{ include "common.fullname" . }}-logging-configmap
152
153         - name: {{ include "common.fullname" . }}-filebeat-conf
154           configMap:
155             name: {{ include "common.release" . }}-modeling-filebeat-configmap
156         - name: {{ include "common.fullname" . }}-data-filebeat
157           emptyDir: {}
158       imagePullSecrets:
159       - name: "{{ include "common.namespace" . }}-docker-registry-key"