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