Merge "[POLICY] update images and fixes"
[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: {{ include "common.release" . }}
25     heritage: {{ .Release.Service }}
26 spec:
27   replicas: {{ .Values.replicaCount }}
28   template:
29     metadata:
30       labels:
31         app: {{ include "common.name" . }}
32         release: {{ include "common.release" . }}
33     spec:
34       initContainers:
35       - command:
36         - sh
37         args:
38         - -c
39         - "cd /config-input && for PFILE in `ls -1 *.conf`; do envsubst <${PFILE} >/config/${PFILE}; done"
40         env:
41         - name: JDBC_USER
42           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
43         - name: JDBC_PASSWORD
44           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
45         volumeMounts:
46         - mountPath: /config-input
47           name: pe
48         - mountPath: /config
49           name: pe-processed
50         image: "{{ .Values.global.envsubstImage }}"
51         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
52         name: {{ include "common.name" . }}-update-config
53       - command:
54         - /root/ready.py
55         args:
56         - --container-name
57         - {{ include "common.release" . }}-galera-config
58         env:
59         - name: NAMESPACE
60           valueFrom:
61             fieldRef:
62               apiVersion: v1
63               fieldPath: metadata.namespace
64         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
65         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
66         name: {{ include "common.name" . }}-readiness
67       containers:
68         - command:
69           - /bin/bash
70           - ./do-start.sh
71           - pap
72           name: {{ include "common.name" . }}
73           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
74           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
75           resources:
76 {{ include "common.resources" . | indent 12 }}
77           ports:
78           - containerPort: {{ .Values.service.externalPort }}
79           - containerPort: {{ .Values.service.externalPort2 }}
80           {{- if eq .Values.liveness.enabled true }}
81           livenessProbe:
82             tcpSocket:
83               port: {{ .Values.service.externalPort }}
84             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
85             periodSeconds: {{ .Values.liveness.periodSeconds }}
86           {{ end -}}
87           readinessProbe:
88             tcpSocket:
89               port: {{ .Values.service.externalPort }}
90             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
91             periodSeconds: {{ .Values.readiness.periodSeconds }}
92           env:
93           - name: PRELOAD_POLICIES
94             value: "{{ .Values.config.preloadPolicies }}"
95           volumeMounts:
96           - mountPath: /etc/localtime
97             name: localtime
98             readOnly: true
99           - mountPath: /tmp/policy-install/config/pap-tweaks.sh
100             name: pe-pap
101             subPath: pap-tweaks.sh
102           - mountPath: /tmp/policy-install/config/paplp.conf
103             name: pe-pap
104             subPath: paplp.conf
105           - mountPath: /tmp/policy-install/config/pap.conf
106             name: pe-pap
107             subPath: pap.conf
108           - mountPath: /tmp/policy-install/config/mysql.conf
109             name: pe-pap
110             subPath: mysql.conf
111           - mountPath: /tmp/policy-install/config/elk.conf
112             name: pe-pap
113             subPath: elk.conf
114           - mountPath: /tmp/policy-install/config/console.conf
115             name: pe-pap
116             subPath: console.conf
117           - mountPath: /tmp/policy-install/config/base.conf
118             name: pe-processed
119             subPath: base.conf
120           - mountPath: /tmp/policy-install/do-start.sh
121             name: pe-scripts
122             subPath: do-start.sh
123           - mountPath: /var/log/onap
124             name: policy-logs
125           - mountPath: /tmp/policy-install/logback.xml
126             name: policy-sdk-logback
127             subPath: logback.xml
128           - mountPath: /tmp/logback.xml
129             name: policy-logback
130             subPath: logback.xml
131           lifecycle:
132             postStart:
133               exec:
134                 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"]
135         - image: "{{ .Values.global.loggingRepository | default .Values.loggingRepository }}/{{ .Values.global.loggingImage | default .Values.loggingImage }}"
136           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
137           name: filebeat-onap
138           volumeMounts:
139           - mountPath: /usr/share/filebeat/filebeat.yml
140             name: filebeat-conf
141             subPath: filebeat.yml
142           - mountPath: /var/log/onap
143             name: policy-logs
144           - mountPath: /usr/share/filebeat/data
145             name: policy-data-filebeat
146       volumes:
147         - name: localtime
148           hostPath:
149             path: /etc/localtime
150         - name: filebeat-conf
151           configMap:
152             name: {{ include "common.release" . }}-filebeat-configmap
153         - name: policy-logs
154           emptyDir: {}
155         - name: policy-data-filebeat
156           emptyDir: {}
157         - name: policy-logback
158           configMap:
159             name: {{ include "common.fullname" . }}-log-configmap
160         - name: policy-sdk-logback
161           configMap:
162             name: {{ include "common.fullname" . }}-sdk-log-configmap
163         - name: pe
164           configMap:
165             name: {{ include "common.release" . }}-pe-configmap
166             defaultMode: 0755
167         - name: pe-scripts
168           configMap:
169             name: {{ include "common.release" . }}-pe-scripts-configmap
170             defaultMode: 0777
171         - name: pe-pap
172           configMap:
173             name: {{ include "common.fullname" . }}-pe-configmap
174             defaultMode: 0755
175         - name: pe-processed
176           emptyDir:
177             medium: Memory
178       imagePullSecrets:
179       - name: "{{ include "common.namespace" . }}-docker-registry-key"