[CONSUL] Add limits to consul chart.
[oom.git] / kubernetes / portal / components / portal-sdk / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 # Modifications Copyright © 2018,2020 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: 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   selector:
28     matchLabels:
29       app: {{ include "common.name" . }}
30   replicas: {{ .Values.replicaCount }}
31   template:
32     metadata:
33       labels:
34         app: {{ include "common.name" . }}
35         release: {{ include "common.release" . }}
36     spec:
37       initContainers:
38       - name: {{ include "common.name" . }}-readiness
39         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
40         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
41         command:
42         - /app/ready.py
43         args:
44         - --container-name
45         - "portal-db"
46         env:
47         - name: NAMESPACE
48           valueFrom:
49             fieldRef:
50               apiVersion: v1
51               fieldPath: metadata.namespace
52       - name: {{ include "common.name" . }}-portalsdk-config
53         image: "{{ .Values.global.envsubstImage }}"
54         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55         command:
56         - sh
57         args:
58         - "-c"
59         - |
60           cd /config-input && \
61           for PFILE in `ls -1 *.xml`
62           do
63             cp ${PFILE} /config
64             chmod 0755 /config/${PFILE}
65           done
66           cd /config-input && \
67           for PFILE in `ls -1 *.properties`
68           do
69             envsubst <${PFILE} >/config/${PFILE}
70             chmod 0755 /config/${PFILE}
71           done
72         env:
73           - name: CASSA_USER
74             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-cass" "key" "login") | indent 12 }}
75           - name: CASSA_PASSWORD
76             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-cass" "key" "password") | indent 12 }}
77           - name: CIPHER_ENC_KEY
78             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cipher-enc-key" "key" "password") | indent 12 }}
79           - name: PORTAL_DB_USER
80             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-backend-db" "key" "login") | indent 12 }}
81           - name: PORTAL_DB_PASSWORD
82             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-backend-db" "key" "password") | indent 12 }}
83         volumeMounts:
84         - mountPath: /config-input
85           name: properties-onapportalsdk-scrubbed
86         - mountPath: /config
87           name: properties-onapportalsdk
88 {{ include "common.certInitializer.initContainer" . | indent 6 }}
89       containers:
90       - name: {{ include "common.name" . }}
91         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
92         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
93         command: ["bash","-c"]
94         {{- if .Values.global.aafEnabled }}
95         args: ["export $(grep '^c' {{ .Values.certInitializer.credsPath }}/mycreds.prop | xargs -0);\
96         export _JAVA_OPTIONS=\"-Djavax.net.ssl.trustStorePassword=$cadi_truststore_password \
97         -Djavax.net.ssl.keyStorePassword=$cadi_keystore_password_p12\";\
98         /start-apache-tomcat.sh -b {{ .Values.global.env.tomcatDir }}"]
99         env:
100           - name: CATALINA_OPTS
101             value: >
102               -Djavax.net.ssl.keyStore="{{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.keystoreFile }}"
103               -Djavax.net.ssl.trustStore="{{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.truststoreFile }}"
104         {{- else }}
105         args: ["/start-apache-tomcat.sh -b {{ .Values.global.env.tomcatDir }}"]
106         {{- end }}
107         ports:
108         - containerPort: {{ .Values.service.internalPort }}
109         {{- if eq .Values.liveness.enabled true }}
110         livenessProbe:
111           tcpSocket:
112             port: {{ .Values.service.internalPort }}
113           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
114           periodSeconds: {{ .Values.liveness.periodSeconds }}
115         {{ end -}}
116         readinessProbe:
117           tcpSocket:
118             port: {{ .Values.service.internalPort }}
119           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
120           periodSeconds: {{ .Values.readiness.periodSeconds }}
121         volumeMounts:
122 {{ include "common.certInitializer.volumeMount" . | indent 8 }}
123         - name: properties-onapportalsdk
124           mountPath: "{{ .Values.global.env.tomcatDir }}/conf/server.xml"
125           subPath: server.xml
126         - mountPath: /etc/localtime
127           name: localtime
128           readOnly: true
129         - name: properties-onapportalsdk
130           mountPath: "{{ .Values.global.env.tomcatDir }}/webapps/ONAPPORTALSDK/WEB-INF/fusion/conf/fusion.properties"
131           subPath: fusion.properties
132         - name: properties-onapportalsdk
133           mountPath: "{{ .Values.global.env.tomcatDir }}/webapps/ONAPPORTALSDK/WEB-INF/conf/system.properties"
134           subPath: system.properties
135         - name: properties-onapportalsdk
136           mountPath: "{{ .Values.global.env.tomcatDir }}/webapps/ONAPPORTALSDK/WEB-INF/classes/portal.properties"
137           subPath: portal.properties
138         - name: properties-onapportalsdk
139           mountPath: "{{ .Values.global.env.tomcatDir }}/webapps/ONAPPORTAL/WEB-INF/classes/key.properties"
140           subPath: key.properties
141         - name: properties-onapportalsdk
142           mountPath: "{{ .Values.global.env.tomcatDir }}/webapps/ONAPPORTALSDK/WEB-INF/classes/music.properties"
143           subPath: music.properties
144         - name: properties-onapportalsdk
145           mountPath: "{{ .Values.global.env.tomcatDir }}/webapps/ONAPPORTALSDK/WEB-INF/classes/logback.xml"
146           subPath: logback.xml
147         - name: portal-tomcat-logs
148           mountPath: "{{ .Values.global.env.tomcatDir }}/logs"
149         - name: var-log-onap
150           mountPath: /var/log/onap
151         resources:
152 {{ include "common.resources" . }}
153       {{- if .Values.nodeSelector }}
154       nodeSelector:
155 {{ toYaml .Values.nodeSelector | indent 10 }}
156       {{- end -}}
157       {{- if .Values.affinity }}
158       affinity:
159 {{ toYaml .Values.affinity | indent 10 }}
160       {{- end }}
161       - name: filebeat-onap
162         image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
163         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
164         volumeMounts:
165         - mountPath: /usr/share/filebeat/filebeat.yml
166           name: filebeat-conf
167           subPath: filebeat.yml
168         - name: portal-data-filebeat
169           mountPath: /usr/share/filebeat/data
170         - name: var-log-onap
171           mountPath: /var/log/onap
172       volumes:
173         - name: localtime
174           hostPath:
175             path: /etc/localtime
176         - name: properties-onapportalsdk
177           emptyDir:
178             medium: Memory
179         - name: properties-onapportalsdk-scrubbed
180           configMap:
181             name: {{ include "common.fullname" . }}-onapportalsdk
182             defaultMode: 0755
183         - name: filebeat-conf
184           configMap:
185             name: portal-filebeat
186         - name: var-log-onap
187           emptyDir: {}
188         - name: portal-data-filebeat
189           emptyDir: {}
190         - name: portal-tomcat-logs
191           emptyDir: {}
192 {{ include "common.certInitializer.volumes" . | indent 8 }}
193       imagePullSecrets:
194       - name: "{{ include "common.namespace" . }}-docker-registry-key"