[SO] Enable SO-Monitoring - use HTTPS and certInitializer
[oom.git] / kubernetes / so / components / so-monitoring / templates / deployment.yaml
1 #  ============LICENSE_START=======================================================
2 #   Copyright (C) 2018 Ericsson. All rights reserved.
3 #   Modifications Copyright © 2020 Nokia
4 #  ================================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #
17 #  SPDX-License-Identifier: Apache-2.0
18 #  ============LICENSE_END=========================================================
19 #  @author: gareth.roper@ericsson.com
20 apiVersion: apps/v1
21 kind: Deployment
22 metadata:
23   name: {{ include "common.fullname" . }}
24   namespace: {{ include "common.namespace" . }}
25   labels:
26     app: {{ include "common.fullname" . }}
27     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
28     release: {{ include "common.release" . }}
29 spec:
30   selector:
31     matchLabels:
32       app: {{ include "common.name" . }}
33   replicas: {{ index .Values.replicaCount }}
34   minReadySeconds: {{ index .Values.minReadySeconds }}
35   strategy:
36     type: {{ index .Values.updateStrategy.type }}
37     rollingUpdate:
38       maxUnavailable: {{ index .Values.updateStrategy.maxUnavailable }}
39       maxSurge: {{ index .Values.updateStrategy.maxSurge }}
40   template:
41     metadata:
42       labels:
43         app: {{ include "common.name" . }}
44         release: {{ include "common.release" . }}
45     spec:
46       initContainers: {{ include "so.certificate.container_importer" . | nindent 6 }}
47       - name: so-chown
48         image: alpine:3.6
49         volumeMounts:
50         - name: logs
51           mountPath: /app/logs
52         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
53         command: ["/bin/sh", "-c", "chown -Rf 1000:1000 /app/logs"]
54       restartPolicy: Always
55       containers:
56       - name: {{ include "common.name" . }}
57         image: {{ include "common.repository" . }}/{{ .Values.image }}
58         resources: {{ include "common.resources" . | nindent 12 }}
59         command:
60         - /bin/sh
61         args:
62         - -c
63         - |
64           export SO_MONITORING_PASSWORD=`htpasswd -bnBC 10 "" $SO_MON_PASS | tr -d ':\n' | sed 's/\$2y/\$2a/'`
65           {{- if .Values.global.aafEnabled }}
66           export $(grep '^c' {{ .Values.soHelpers.certInitializer.credsPath }}/org.onap.so.cred.props | xargs -0)
67           export $(grep '^c' {{ .Values.soHelpers.certInitializer.credsPath }}/mycreds.prop | xargs -0)
68           export KEYSTORE=file://$cadi_keystore
69           export KEYSTORE_PASSWORD=$cadi_keystore_password_p12
70           export TRUSTSTORE=file://$cadi_truststore
71           export TRUSTSTORE_PASSWORD=$cadi_truststore_password
72           {{- end }}
73           /app/start-app.sh
74         env:
75         - name: DB_HOST
76           valueFrom:
77             secretKeyRef:
78               name: {{ include "common.release" . }}-so-db-secrets
79               key: mariadb.readwrite.host
80         - name: DB_PORT
81           valueFrom:
82             secretKeyRef:
83               name: {{ include "common.release" . }}-so-db-secrets
84               key: mariadb.readwrite.port
85         - name: DB_USERNAME
86           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "login") | indent 10 }}
87         - name: DB_PASSWORD
88           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "password") | indent 10 }}
89         - name: DB_ADMIN_USERNAME
90           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "login") | indent 10 }}
91         - name: DB_ADMIN_PASSWORD
92           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "password") | indent 10 }}
93         - name: SO_MONITORING_USERNAME
94           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-user-creds" "key" "login") | indent 10 }}
95         - name: SO_MON_PASS
96           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-user-creds" "key" "password") | indent 10 }}
97
98         envFrom:
99         - configMapRef:
100             name: {{ include "common.fullname" . }}-configmap
101         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
102         volumeMounts: {{ include "so.certificate.volumeMount" . | nindent 8 }}
103         - name: logs
104           mountPath: /app/logs
105         - name: config
106           mountPath: /app/config
107           readOnly: true
108         readinessProbe:
109           tcpSocket:
110             port: {{ index .Values.readinessProbe.port }}
111           initialDelaySeconds: {{ index .Values.readinessProbe.initialDelaySeconds}}
112           periodSeconds: {{ index .Values.readinessProbe.periodSeconds}}
113         livenessProbe:
114           tcpSocket:
115             port: {{ index .Values.livenessProbe.port }}
116           initialDelaySeconds: {{ index .Values.livenessProbe.initialDelaySeconds}}
117           periodSeconds: {{ index .Values.livenessProbe.periodSeconds}}
118           successThreshold: {{ index .Values.livenessProbe.successThreshold}}
119           failureThreshold: {{ index .Values.livenessProbe.failureThreshold}}
120
121         ports:
122         - containerPort: {{ index .Values.containerPort }}
123           name: {{ .Values.service.portName }}
124           protocol: TCP
125       volumes: {{ include "so.certificate.volumes" . | nindent 6 }}
126       - name: logs
127         emptyDir: {}
128       - name: config
129         configMap:
130             name: {{ include "common.fullname" . }}-app-configmap
131       imagePullSecrets:
132         - name: "{{ include "common.namespace" . }}-docker-registry-key"