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