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