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