Merge "Mounting logback.xml file to champ MS"
[oom.git] / kubernetes / policy / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 # Modifications Copyright © 2018 AT&T
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 apiVersion: extensions/v1beta1
17 kind: Deployment
18 metadata:
19   name: {{ include "common.fullname" . }}
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ .Release.Name }}
25     heritage: {{ .Release.Service }}
26 spec:
27   replicas: {{ .Values.replicaCount }}
28   template:
29     metadata:
30       labels:
31         app: {{ include "common.name" . }}
32         release: {{ .Release.Name }}
33     spec:
34       initContainers:
35       - command:
36         - /root/ready.py
37         args:
38         - --container-name
39         - {{ .Values.global.mariadb.nameOverride }}
40         env:
41         - name: NAMESPACE
42           valueFrom:
43             fieldRef:
44               apiVersion: v1
45               fieldPath: metadata.namespace
46         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
47         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
48         name: {{ include "common.name" . }}-readiness
49       containers:
50         - command:
51           - /bin/bash
52           - ./do-start.sh
53           - pap
54           name: {{ include "common.name" . }}
55           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
56           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
57           ports:
58           - containerPort: {{ .Values.service.externalPort }}
59           - containerPort: {{ .Values.service.externalPort2 }}
60           {{- if eq .Values.liveness.enabled true }}
61           livenessProbe:
62             tcpSocket:
63               port: {{ .Values.service.externalPort }}
64             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
65             periodSeconds: {{ .Values.liveness.periodSeconds }}
66           {{ end -}}
67           readinessProbe:
68             tcpSocket:
69               port: {{ .Values.service.externalPort }}
70             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
71             periodSeconds: {{ .Values.readiness.periodSeconds }}
72           env:
73           - name: PRELOAD_POLICIES
74             value: "{{ .Values.config.preloadPolicies }}"
75           volumeMounts:
76           - mountPath: /etc/localtime
77             name: localtime
78             readOnly: true
79           - mountPath: /tmp/policy-install/config/push-policies.sh
80             name: pe-pap
81             subPath: push-policies.sh
82           - mountPath: /tmp/policy-install/config/pap-tweaks.sh
83             name: pe-pap
84             subPath: pap-tweaks.sh
85           - mountPath: /tmp/policy-install/config/paplp.conf
86             name: pe-pap
87             subPath: paplp.conf
88           - mountPath: /tmp/policy-install/config/pap.conf
89             name: pe-pap
90             subPath: pap.conf
91           - mountPath: /tmp/policy-install/config/mysql.conf
92             name: pe-pap
93             subPath: mysql.conf
94           - mountPath: /tmp/policy-install/config/elk.conf
95             name: pe-pap
96             subPath: elk.conf
97           - mountPath: /tmp/policy-install/config/console.conf
98             name: pe-pap
99             subPath: console.conf
100           - mountPath: /tmp/policy-install/config/base.conf
101             name: pe
102             subPath: base.conf
103           - mountPath: /tmp/policy-install/do-start.sh
104             name: pe-scripts
105             subPath: do-start.sh
106           - mountPath: /var/log/onap
107             name: policy-logs
108           - mountPath: /tmp/policy-install/logback.xml
109             name: policy-sdk-logback
110             subPath: logback.xml
111           - mountPath: /tmp/logback.xml
112             name: policy-logback
113             subPath: logback.xml
114           lifecycle:
115             postStart:
116               exec:
117                 command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/opt/app/policy/servers/pap/webapps/pap/WEB-INF/classes/; while [ ! -e $DST ]; do echo 'Waiting for $DST...' >> $LOG; sleep 5; done; sleep 2; /bin/cp -f $SRC $DST; export SRC=/tmp/policy-install/logback.xml; export DST=/opt/app/policy/servers/console/webapps/onap/WEB-INF/classes/; while [ ! -e $DST ]; do echo 'Waiting for $DST...' >> $LOG; sleep 5; done; sleep 2; /bin/cp -f $SRC $DST; echo 'Done' >> $LOG"]
118         - image: "{{ .Values.global.loggingRepository | default .Values.loggingRepository }}/{{ .Values.global.loggingImage | default .Values.loggingImage }}"
119           imagePullPolicy: {{ .Values.pullPolicy }}
120           name: filebeat-onap
121           volumeMounts:
122           - mountPath: /usr/share/filebeat/filebeat.yml
123             name: filebeat-conf
124             subPath: filebeat.yml
125           - mountPath: /var/log/onap
126             name: policy-logs
127           - mountPath: /usr/share/filebeat/data
128             name: policy-data-filebeat
129           resources:
130 {{ toYaml .Values.resources | indent 12 }}
131         {{- if .Values.nodeSelector }}
132         nodeSelector:
133 {{ toYaml .Values.nodeSelector | indent 10 }}
134         {{- end -}}
135         {{- if .Values.affinity }}
136         affinity:
137 {{ toYaml .Values.affinity | indent 10 }}
138         {{- end }}
139       volumes:
140         - name: localtime
141           hostPath:
142             path: /etc/localtime
143         - name: filebeat-conf
144           configMap:
145             name: {{ .Release.Name }}-filebeat-configmap
146         - name: policy-logs
147           emptyDir: {}
148         - name: policy-data-filebeat
149           emptyDir: {}
150         - name: policy-logback
151           configMap:
152             name: {{ include "common.fullname" . }}-log-configmap
153         - name: policy-sdk-logback
154           configMap:
155             name: {{ include "common.fullname" . }}-sdk-log-configmap
156         - name: pe
157           configMap:
158             name: {{ .Release.Name }}-pe-configmap
159             defaultMode: 0755
160         - name: pe-scripts
161           configMap:
162             name: {{ .Release.Name }}-pe-scripts-configmap
163             defaultMode: 0777
164         - name: pe-pap
165           configMap:
166             name: {{ include "common.fullname" . }}-pe-configmap
167             defaultMode: 0755
168       imagePullSecrets:
169       - name: "{{ include "common.namespace" . }}-docker-registry-key"