[POLICY] Use common secret template in pdp
[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/v1beta1
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 `ls -1 *.conf`; do envsubst <${PFILE} >/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
59           name: pe
60         - mountPath: /config
61           name: pe-processed
62         image: "{{ .Values.global.envsubstImage }}"
63         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
64         name: {{ include "common.name" . }}-update-config
65       - command:
66         - /root/ready.py
67         args:
68         - --container-name
69         - {{ .Values.global.pap.nameOverride }}
70         env:
71         - name: NAMESPACE
72           valueFrom:
73             fieldRef:
74               apiVersion: v1
75               fieldPath: metadata.namespace
76         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
77         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         name: {{ include "common.name" . }}-readiness
79       containers:
80       - command:
81         - /bin/bash
82         - ./do-start.sh
83         - pdp
84         name: {{ include "common.name" . }}
85         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
86         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
87         env:
88         - name: JDBC_USER
89           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
90         - name: JDBC_PASSWORD
91           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
92         - name: PDP_HTTP_USER_ID
93           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pdp-http-creds" "key" "login") | indent 10 }}
94         - name: PDP_HTTP_PASSWORD
95           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pdp-http-creds" "key" "password") | indent 10 }}
96         - name: PDP_PAP_PDP_HTTP_USER_ID
97           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pap-http-creds" "key" "login") | indent 10 }}
98         - name: PDP_PAP_PDP_HTTP_PASSWORD
99           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pap-http-creds" "key" "password") | indent 10 }}
100         resources:
101 {{ include "common.resources" . | indent 12 }}
102         ports:
103         - containerPort: {{ .Values.service.externalPort }}
104         {{- if eq .Values.liveness.enabled true }}
105         livenessProbe:
106           tcpSocket:
107             port: {{ .Values.service.externalPort }}
108           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
109           periodSeconds: {{ .Values.liveness.periodSeconds }}
110         {{- end }}
111         readinessProbe:
112           tcpSocket:
113             port: {{ .Values.service.externalPort }}
114           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
115           periodSeconds: {{ .Values.readiness.periodSeconds }}
116         volumeMounts:
117         - mountPath: /etc/localtime
118           name: localtime
119           readOnly: true
120         - mountPath: /tmp/policy-install/config/base.conf
121           name: pe-processed
122           subPath: base.conf
123         - mountPath: /tmp/policy-install/config/pdp-tweaks.sh
124           name: pe-pdp
125           subPath: pdp-tweaks.sh
126         - mountPath: /tmp/policy-install/config/pdplp.conf
127           name: pe-pdp
128           subPath: pdplp.conf
129         - mountPath: /tmp/policy-install/config/pdp.conf
130           name: pe-pdp
131           subPath: pdp.conf
132         - mountPath: /tmp/policy-install/do-start.sh
133           name: pe-scripts
134           subPath: do-start.sh
135         - mountPath: /var/log/onap
136           name: policy-logs
137         - mountPath:  /tmp/logback.xml
138           name: policy-logback
139           subPath: logback.xml
140         lifecycle:
141           postStart:
142             exec:
143               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"]
144       - image: {{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}
145         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
146         name: filebeat-onap
147         volumeMounts:
148         - mountPath: /usr/share/filebeat/filebeat.yml
149           name: filebeat-conf
150           subPath: filebeat.yml
151         - mountPath: /var/log/onap
152           name: policy-logs
153         - mountPath: /usr/share/filebeat/data
154           name: policy-data-filebeat
155       volumes:
156       - name: localtime
157         hostPath:
158           path: /etc/localtime
159       - name: filebeat-conf
160         configMap:
161           name: {{ include "common.release" . }}-filebeat-configmap
162       - name: policy-logs
163         emptyDir: {}
164       - name: policy-data-filebeat
165         emptyDir: {}
166       - name: policy-logback
167         configMap:
168           name: {{ include "common.fullname" . }}-log-configmap
169       - name: pe
170         configMap:
171           name: {{ include "common.release" . }}-pe-configmap
172           defaultMode: 0755
173       - name: pe-scripts
174         configMap:
175           name: {{ include "common.release" . }}-pe-scripts-configmap
176           defaultMode: 0777
177       - name: pe-pdp
178         configMap:
179           name: {{ include "common.fullname" . }}-pe-configmap
180           defaultMode: 0755
181       - name: pe-processed
182         emptyDir:
183           medium: Memory
184       imagePullSecrets:
185       - name: "{{ include "common.namespace" . }}-docker-registry-key"