Merge "clamphealth check"
[oom.git] / kubernetes / policy / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 apiVersion: extensions/v1beta1
16 kind: Deployment
17 metadata:
18   name: {{ include "common.fullname" . }}
19   namespace: {{ include "common.namespace" . }}
20   labels:
21     app: {{ include "common.name" . }}
22     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23     release: {{ .Release.Name }}
24     heritage: {{ .Release.Service }}
25 spec:
26   replicas: {{ .Values.replicaCount }}
27   template:
28     metadata:
29       labels:
30         app: {{ include "common.name" . }}
31         release: {{ .Release.Name }}
32     spec:
33       initContainers:
34       - command:
35         - /root/ready.py
36         args:
37         - --container-name
38         - {{ .Values.global.mariadb.nameOverride }}
39         env:
40         - name: NAMESPACE
41           valueFrom:
42             fieldRef:
43               apiVersion: v1
44               fieldPath: metadata.namespace
45         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
46         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
47         name: {{ include "common.name" . }}-readiness
48       containers:
49         - command:
50           - /bin/bash
51           - ./do-start.sh
52           - pap
53           name: {{ include "common.name" . }}
54           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
55           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
56           ports:
57           - containerPort: {{ .Values.service.externalPort }}
58           - containerPort: {{ .Values.service.externalPort2 }}
59           {{- if eq .Values.liveness.enabled true }}
60           livenessProbe:
61             tcpSocket:
62               port: {{ .Values.service.externalPort }}
63             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
64             periodSeconds: {{ .Values.liveness.periodSeconds }}
65           {{ end -}}
66           readinessProbe:
67             tcpSocket:
68               port: {{ .Values.service.externalPort }}
69             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
70             periodSeconds: {{ .Values.readiness.periodSeconds }}
71           env:
72           - name: PRELOAD_POLICIES
73             value: "{{ .Values.config.preloadPolicies }}"
74           volumeMounts:
75           - mountPath: /etc/localtime
76             name: localtime
77             readOnly: true
78           - mountPath: /tmp/policy-install/config/push-policies.sh
79             name: pe-pap
80             subPath: push-policies.sh
81           - mountPath: /tmp/policy-install/config/pap-tweaks.sh
82             name: pe-pap
83             subPath: pap-tweaks.sh
84           - mountPath: /tmp/policy-install/config/paplp.conf
85             name: pe-pap
86             subPath: paplp.conf
87           - mountPath: /tmp/policy-install/config/pap.conf
88             name: pe-pap
89             subPath: pap.conf
90           - mountPath: /tmp/policy-install/config/mysql.conf
91             name: pe-pap
92             subPath: mysql.conf
93           - mountPath: /tmp/policy-install/config/elk.conf
94             name: pe-pap
95             subPath: elk.conf
96           - mountPath: /tmp/policy-install/config/console.conf
97             name: pe-pap
98             subPath: console.conf
99           - mountPath: /tmp/policy-install/config/base.conf
100             name: pe
101             subPath: base.conf
102           - mountPath: /tmp/policy-install/do-start.sh
103             name: pe-scripts
104             subPath: do-start.sh
105           - mountPath: /var/log/onap
106             name: policy-logs
107           - mountPath: /tmp/policy-install/logback.xml
108             name: policy-sdk-logback
109             subPath: logback.xml
110           - mountPath: /tmp/logback.xml
111             name: policy-logback
112             subPath: logback.xml
113           lifecycle:
114             postStart:
115               exec:
116                 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"]
117         - image: "{{ .Values.global.loggingRepository | default .Values.loggingRepository }}/{{ .Values.global.loggingImage | default .Values.loggingImage }}"
118           imagePullPolicy: {{ .Values.pullPolicy }}
119           name: filebeat-onap
120           volumeMounts:
121           - mountPath: /usr/share/filebeat/filebeat.yml
122             name: filebeat-conf
123             subPath: filebeat.yml
124           - mountPath: /var/log/onap
125             name: policy-logs
126           - mountPath: /usr/share/filebeat/data
127             name: policy-data-filebeat
128           resources:
129 {{ toYaml .Values.resources | indent 12 }}
130         {{- if .Values.nodeSelector }}
131         nodeSelector:
132 {{ toYaml .Values.nodeSelector | indent 10 }}
133         {{- end -}}
134         {{- if .Values.affinity }}
135         affinity:
136 {{ toYaml .Values.affinity | indent 10 }}
137         {{- end }}
138       volumes:
139         - name: localtime
140           hostPath:
141             path: /etc/localtime
142         - name: filebeat-conf
143           configMap:
144             name: {{ .Release.Name }}-filebeat-configmap
145         - name: policy-logs
146           emptyDir: {}
147         - name: policy-data-filebeat
148           emptyDir: {}
149         - name: policy-logback
150           configMap:
151             name: {{ include "common.fullname" . }}-log-configmap
152         - name: policy-sdk-logback
153           configMap:
154             name: {{ include "common.fullname" . }}-sdk-log-configmap
155         - name: pe
156           configMap:
157             name: {{ .Release.Name }}-pe-configmap
158             defaultMode: 0755
159         - name: pe-scripts
160           configMap:
161             name: {{ .Release.Name }}-pe-scripts-configmap
162             defaultMode: 0777
163         - name: pe-pap
164           configMap:
165             name: {{ include "common.fullname" . }}-pe-configmap
166             defaultMode: 0755
167       imagePullSecrets:
168       - name: "{{ include "common.namespace" . }}-docker-registry-key"