[DMAAP] DMaaP ServiceMesh compatibility
[oom.git] / kubernetes / policy / components / policy-pap / templates / deployment.yaml
1 {{/*
2 #  ============LICENSE_START=======================================================
3 #   Copyright (C) 2020 AT&T Intellectual Property.
4 #   Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
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 */}}
21
22 apiVersion: apps/v1
23 kind: Deployment
24 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
25 spec:
26   selector: {{- include "common.selectors" . | nindent 4 }}
27   replicas: {{ .Values.replicaCount }}
28   template:
29     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
30     spec:
31       initContainers:
32       - command:
33         - /app/ready.py
34         args:
35         - --job-name
36         - {{ include "common.release" . }}-policy-galera-config
37         env:
38         - name: NAMESPACE
39           valueFrom:
40             fieldRef:
41               apiVersion: v1
42               fieldPath: metadata.namespace
43         image: {{ include "repositoryGenerator.image.readiness" . }}
44         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
45         name: {{ include "common.name" . }}-readiness
46       - command:
47         - sh
48         args:
49         - -c
50         - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done"
51         env:
52         - name: SQL_USER
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
54         - name: SQL_PASSWORD
55           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
56         - name: RESTSERVER_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-secret" "key" "login") | indent 10 }}
58         - name: RESTSERVER_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-secret" "key" "password") | indent 10 }}
60         - name: API_USER
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-secret" "key" "login") | indent 10 }}
62         - name: API_PASSWORD
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-secret" "key" "password") | indent 10 }}
64         - name: DISTRIBUTION_USER
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "distribution-secret" "key" "login") | indent 10 }}
66         - name: DISTRIBUTION_PASSWORD
67           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "distribution-secret" "key" "password") | indent 10 }}
68         volumeMounts:
69         - mountPath: /config-input
70           name: papconfig
71         - mountPath: /config
72           name: papconfig-processed
73         image: {{ include "repositoryGenerator.image.envsubst" . }}
74         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
75         name: {{ include "common.name" . }}-update-config
76 {{ include "common.certInitializer.initContainer" . | indent 6 }}
77       containers:
78         - name: {{ include "common.name" . }}
79           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
80           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
81 {{- if .Values.global.aafEnabled }}
82           command: ["sh","-c"]
83           args: ["source {{ .Values.certInitializer.credsPath }}/.ci;\
84                   /opt/app/policy/pap/bin/policy-pap.sh /opt/app/policy/pap/etc/mounted/papParameters.yaml"]
85 {{- else }}
86           command: ["/opt/app/policy/pap/bin/policy-pap.sh"]
87           args: ["/opt/app/policy/pap/etc/mounted/papParameters.yaml"]
88           env:
89           - name: KEYSTORE_PASSWD
90             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "keystore-password" "key" "password") | indent 12 }}
91           - name: TRUSTSTORE_PASSWD
92             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "truststore-password" "key" "password") | indent 12 }}
93 {{- end }}
94           ports: {{ include "common.containerPorts" . | nindent 12  }}
95           # disable liveness probe when breakpoints set in debugger
96           # so K8s doesn't restart unresponsive container
97           {{- if eq .Values.liveness.enabled true }}
98           livenessProbe:
99             tcpSocket:
100               port: {{ .Values.liveness.port }}
101             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
102             periodSeconds: {{ .Values.liveness.periodSeconds }}
103           {{ end -}}
104           readinessProbe:
105             httpGet:
106               path: {{ .Values.readiness.api }}
107               port: {{ .Values.readiness.port }}
108               httpHeaders:
109                 - name: Authorization
110                   value: Basic {{ printf "%s:%s" .Values.restServer.user .Values.restServer.password | b64enc }}
111               scheme: {{ .Values.readiness.scheme }}
112             successThreshold: {{ .Values.readiness.successThreshold }}
113             failureThreshold: {{ .Values.readiness.failureThreshold }}
114             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
115             periodSeconds: {{ .Values.readiness.periodSeconds }}
116             timeoutSeconds: {{ .Values.readiness.timeout }}
117           volumeMounts:
118 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
119           - mountPath: /etc/localtime
120             name: localtime
121             readOnly: true
122           - mountPath: /opt/app/policy/pap/etc/mounted
123             name: papconfig-processed
124           resources:
125 {{ include "common.resources" . }}
126         {{- if .Values.nodeSelector }}
127         nodeSelector:
128 {{ toYaml .Values.nodeSelector | indent 10 }}
129         {{- end -}}
130         {{- if .Values.affinity }}
131         affinity:
132 {{ toYaml .Values.affinity | indent 10 }}
133         {{- end }}
134       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
135       volumes:
136 {{ include "common.certInitializer.volumes" . | indent 8 }}
137         - name: localtime
138           hostPath:
139              path: /etc/localtime
140         - name: papconfig
141           configMap:
142             name: {{ include "common.fullname" . }}-configmap
143             defaultMode: 0755
144         - name: papconfig-processed
145           emptyDir:
146             medium: Memory
147       imagePullSecrets:
148       - name: "{{ include "common.namespace" . }}-docker-registry-key"