Merge "[DCAEMOD] Uses new tpls for repos / images"
[oom.git] / kubernetes / dmaap / components / dmaap-bc / templates / deployment.yaml
1 {{/*
2 # Modifications Copyright © 2018 Amdocs,Bell Canada
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
17 apiVersion: apps/v1
18 kind: Deployment
19 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
20 spec:
21   selector: {{- include "common.selectors" . | nindent 4 }}
22   replicas: {{ .Values.replicaCount }}
23   template:
24     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
25     spec:
26 {{- if or .Values.global.aafEnabled .Values.PG.enabled }}
27       initContainers:
28       - command:
29         - sh
30         args:
31         - -c
32         - "cd /config-input && for PFILE in `find . -not -type d | grep -v -F ..`; do envsubst <${PFILE} >/config/${PFILE}; done"
33         env:
34         - name: PG_USER
35           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
36         - name: PG_PASSWORD
37           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
38         volumeMounts:
39         - mountPath: /config-input
40           name: {{ include "common.name" . }}-config-input
41         - mountPath: /config
42           name: {{ include "common.name" . }}-config
43         image: {{ include "repositoryGenerator.image.envsubst" . }}
44         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
45         name: {{ include "common.name" . }}-update-config
46 {{ include "common.certInitializer.initContainer" . | nindent 6 }}
47       - name: {{ include "common.name" . }}-permission-fixer
48         image: {{ include "repositoryGenerator.image.busybox" . }}
49         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
51         command: ["chown","-Rf","1000:1001", "/opt/app/"]
52 #       See AAF-425 for explanation of why this is needed.
53 #       This artifact is provisioned in AAF for both pks12 and jks format and apparently
54 #       the cadi library is not using the jks password on the jks keystore.
55 #       So, this attempts to "fix" the credential property file until this is fixed properly.
56       - name: {{ include "common.name" . }}-cred-fixer
57         image: {{ include "repositoryGenerator.image.busybox" . }}
58         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
60         command: ["/bin/sh"]
61         args: [ "-c", "sed -i -e '/cadi_keystore_password=/d' -e '/cadi_keystore_password_jks/p' -e 's/cadi_keystore_password_jks/cadi_keystore_password/' -e 's/dmaap-bc.p12/dmaap-bc.jks/' /opt/app/osaaf/local/org.onap.dmaap-bc.cred.props" ]
62       - name: {{ include "common.name" . }}-postgres-readiness
63         command:
64         - /app/ready.py
65         args:
66         - --container-name
67         - {{ .Values.postgres.nameOverride }}
68         - --container-name
69         - message-router
70         - --container-name
71         - dmaap-dr-node
72         env:
73         - name: NAMESPACE
74           valueFrom:
75             fieldRef:
76               apiVersion: v1
77               fieldPath: metadata.namespace
78         image: {{ include "repositoryGenerator.image.readiness" . }}
79         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
80 {{- end }}
81       containers:
82         - name: {{ include "common.name" . }}
83           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
84           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
85           ports: {{ include "common.containerPorts" . | nindent 10  }}
86           {{ if eq .Values.liveness.enabled true -}}
87           livenessProbe:
88             httpGet:
89               port: {{ .Values.liveness.port }}
90               path: /webapi/topics
91               scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
92             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
93             periodSeconds: {{ .Values.liveness.periodSeconds }}
94           {{ end -}}
95           readinessProbe:
96             httpGet:
97               port: {{ .Values.readiness.port }}
98               path: /webapi/topics
99               scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
100             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
101             periodSeconds: {{ .Values.readiness.periodSeconds }}
102           volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
103           - mountPath: /etc/localtime
104             name: localtime
105             readOnly: true
106 # NOTE: on the following several configMaps, careful to include / at end
107 #       since there may be more than one file in each mountPath
108           - name: {{ include "common.name" . }}-config
109             mountPath: /opt/app/config/conf/
110           resources: {{ include "common.resources" . | nindent 12 }}
111         {{- if .Values.nodeSelector }}
112         nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
113         {{- end -}}
114         {{- if .Values.affinity }}
115         affinity: {{ toYaml .Values.affinity | nindent 10 }}
116         {{- end }}
117       volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
118         - name: localtime
119           hostPath:
120             path: /etc/localtime
121         - name: {{ include "common.name" . }}-config-input
122           configMap:
123             name: {{ include "common.fullname" . }}-config
124         - name: {{ include "common.name" . }}-config
125           emptyDir:
126             medium: Memory
127       imagePullSecrets:
128       - name: "{{ include "common.namespace" . }}-docker-registry-key"