Merge "[CONSUL] Add limits to consul chart."
[oom.git] / kubernetes / so / templates / deployment.yaml
1 # Copyright © 2018 AT&T USA
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 apiVersion: apps/v1
15 kind: Deployment
16 metadata:
17   name: {{ include "common.fullname" . }}
18   namespace: {{ include "common.namespace" . }}
19   labels:
20     app: {{ include "common.fullname" . }}
21     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
22     release: {{ include "common.release" . }}
23 spec:
24   selector:
25     matchLabels:
26       app: {{ include "common.name" . }}
27   replicas: {{ index .Values.replicaCount }}
28   minReadySeconds: {{ index .Values.minReadySeconds }}
29   strategy:
30     type: {{ index .Values.updateStrategy.type }}
31     rollingUpdate:
32       maxUnavailable: {{ index .Values.updateStrategy.maxUnavailable }}
33       maxSurge: {{ index .Values.updateStrategy.maxSurge }}
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ include "common.release" . }}
39     spec:
40       initContainers:
41       {{ include "so.certificate.container_importer" . | indent 6 | trim }}
42       - name: {{ include "common.name" . }}-readiness
43         command:
44         - /app/ready.py
45         args:
46         - --job-name
47         - {{ include "common.release" . }}-so-mariadb-config-job
48         env:
49         - name: NAMESPACE
50           valueFrom:
51             fieldRef:
52               apiVersion: v1
53               fieldPath: metadata.namespace
54         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
55         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
56       containers:
57       - name: {{ include "common.name" . }}
58         image: {{ include "common.repository" . }}/{{ .Values.image }}
59         resources: {{ include "common.resources" . | nindent 12 }}
60         {{- if .Values.global.aafEnabled }}
61         command:
62         - sh
63         args:
64         - -c
65         - |
66           export $(grep '^c' {{ .Values.soHelpers.certInitializer.credsPath }}/mycreds.prop | xargs -0)
67           export TRUSTSTORE_PASSWORD="${cadi_truststore_password}"
68           {{- if .Values.global.security.aaf.enabled }}
69           export KEYSTORE_PASSWORD="${cadi_keystore_password}"
70           {{- end }}
71           /app/start-app.sh
72         {{- end }}
73         env:
74         - name: DB_HOST
75           valueFrom:
76             secretKeyRef:
77               name: {{ include "common.release" . }}-so-db-secrets
78               key: mariadb.readwrite.host
79         - name: DB_PORT
80           valueFrom:
81             secretKeyRef:
82               name: {{ include "common.release" . }}-so-db-secrets
83               key: mariadb.readwrite.port
84         - name: DB_USERNAME
85           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "login") | indent 10 }}
86         - name: DB_PASSWORD
87           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "password") | indent 10 }}
88         - name: DB_ADMIN_USERNAME
89           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "login") | indent 10 }}
90         - name: DB_ADMIN_PASSWORD
91           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "password") | indent 10 }}
92         {{ include "so.certificates.env" . | indent 8 | trim }}
93         envFrom:
94         - configMapRef:
95             name: {{ include "common.fullname" . }}-configmap
96         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
97         volumeMounts: {{ include "so.certificate.volumeMount" . | nindent 8 }}
98         - name: logs
99           mountPath: /app/logs
100         - name: config
101           mountPath: /app/config
102           readOnly: true
103         - name: {{ include "common.fullname" . }}-logs
104           mountPath: /var/log/onap
105 {{ include "so.helpers.livenessProbe" .| indent 8 }}
106         ports:
107         - containerPort: {{ index .Values.containerPort }}
108           name: {{ .Values.service.portName }}
109           protocol: TCP
110       # Filebeat sidecar container
111       - name: {{ include "common.name" . }}-filebeat-onap
112         image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
113         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
114         volumeMounts:
115         - name: {{ include "common.fullname" . }}-filebeat-conf
116           mountPath: /usr/share/filebeat/filebeat.yml
117           subPath: filebeat.yml
118         - name: {{ include "common.fullname" . }}-data-filebeat
119           mountPath: /usr/share/filebeat/data
120         - name: logs
121           mountPath: /var/log/onap/so
122         - name: {{ include "common.fullname" . }}-logs
123           mountPath: /var/log/onap
124       volumes: {{ include "so.certificate.volumes" . | nindent 6 }}
125       - name: logs
126         emptyDir: {}
127       - name: config
128         configMap:
129             name: {{ include "common.fullname" . }}-app-configmap
130       - name: {{ include "common.fullname" . }}-log-conf
131         configMap:
132           name: {{ include "common.fullname" . }}-log
133       - name: {{ include "common.fullname" . }}-filebeat-conf
134         configMap:
135           name: {{ .Release.Name }}-so-filebeat-configmap
136       - name: {{ include "common.fullname" . }}-data-filebeat
137         emptyDir: {}
138       - name:  {{ include "common.fullname" . }}-logs
139         emptyDir: {}
140       imagePullSecrets:
141         - name: "{{ include "common.namespace" . }}-docker-registry-key"