[MSB] Make MSB ServiceMesh compatible
[oom.git] / kubernetes / msb / components / msb-eag / templates / deployment.yaml
1 {{/*
2 # Copyright © 2018 Amdocs, Bell Canada , ZTE
3 # Copyright © 2021 Orange
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 */}}
17 apiVersion: apps/v1
18 kind: Deployment
19 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
20 spec:
21   selector: {{- include "common.selectors" . | nindent 4 }}
22   replicas: {{ .Values.replicaCount }}
23   template:
24     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
25     spec:
26       initContainers:
27       {{ include "common.certInitializer.initContainer" . | indent 6 | trim }}
28       - command:
29         - /app/ready.py
30         args:
31         - --container-name
32         - msb-discovery
33         env:
34         - name: NAMESPACE
35           valueFrom:
36             fieldRef:
37               apiVersion: v1
38               fieldPath: metadata.namespace
39         image: {{ include "repositoryGenerator.image.readiness" . }}
40         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
41         name: {{ include "common.name" . }}-readiness
42       containers:
43         - name: {{ include "common.name" . }}
44           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
45           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
46           ports: {{- include "common.containerPorts" . | indent 10 }}
47           # disable liveness probe when breakpoints set in debugger
48           # so K8s doesn't restart unresponsive container
49           {{- if eq .Values.liveness.enabled true }}
50           livenessProbe:
51             tcpSocket:
52               port: {{ (eq "true" (include "common.needTLS" .)) | ternary .Values.service.internalPort .Values.service.internalPlainPort }}
53             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
54             periodSeconds: {{ .Values.liveness.periodSeconds }}
55           {{ end -}}
56           readinessProbe:
57             tcpSocket:
58               port: {{ (eq "true" (include "common.needTLS" .)) | ternary .Values.service.internalPort .Values.service.internalPlainPort }}
59             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
60             periodSeconds: {{ .Values.readiness.periodSeconds }}
61           env:
62           - name: CONSUL_IP
63             value: msb-consul.{{ include "common.namespace" . }}
64           - name: SDCLIENT_IP
65             value: msb-discovery.{{ include "common.namespace" . }}
66           - name: ROUTE_LABELS
67             value: {{ .Values.config.routeLabels }}
68           volumeMounts:
69           {{ include "common.certInitializer.volumeMount" . | indent 10 | trim }}
70           - mountPath: /etc/localtime
71             name: localtime
72             readOnly: true
73           - mountPath: /usr/local/apiroute-works/logs
74             name: {{ include "common.fullname" . }}-logs
75           {{- if (include "common.needTLS" .) }}
76           - mountPath: /usr/local/openresty/nginx/msb-enabled/msbhttps.conf
77             name: {{ include "common.fullname" . }}-nginx-conf
78             subPath: msbhttps.conf
79           {{- end }}
80           resources:
81 {{ include "common.resources" . | indent 12 }}
82         {{- if .Values.nodeSelector }}
83         nodeSelector:
84 {{ toYaml .Values.nodeSelector | indent 10 }}
85         {{- end -}}
86         {{- if .Values.affinity }}
87         affinity:
88 {{ toYaml .Values.affinity | indent 10 }}
89         {{- end }}
90         # side car containers
91         {{ include "common.log.sidecar" . | nindent 8 }}
92       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
93       volumes:
94         {{ include "common.certInitializer.volumes" . | indent 8 | trim }}
95         - name: {{ include "common.fullname" . }}-log-conf
96           configMap:
97             name: {{ include "common.fullname" . }}-log
98         {{- if (include "common.needTLS" .) }}
99         - name: {{ include "common.fullname" . }}-nginx-conf
100           configMap:
101             name: {{ include "common.fullname" . }}-nginx
102         {{- end }}
103         {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix . )) | nindent 8 }}
104         - name:  {{ include "common.fullname" . }}-logs
105           emptyDir: {}
106         - name: localtime
107           hostPath:
108             path: /etc/localtime
109       imagePullSecrets:
110       - name: "{{ include "common.namespace" . }}-docker-registry-key"