[CONSUL] Add limits to consul chart.
[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         - "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                   /opt/app/policy/pap/bin/policy-pap.sh /opt/app/policy/pap/etc/mounted/config.json"]
82 {{- else }}
83           command: ["/opt/app/policy/pap/bin/policy-pap.sh"]
84           args: ["/opt/app/policy/pap/etc/mounted/config.json"]
85           env:
86           - name: KEYSTORE_PASSWD
87             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "keystore-password" "key" "password") | indent 12 }}
88           - name: TRUSTSTORE_PASSWD
89             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "truststore-password" "key" "password") | indent 12 }}
90 {{- end }}
91           ports: {{ include "common.containerPorts" . | nindent 12  }}
92           # disable liveness probe when breakpoints set in debugger
93           # so K8s doesn't restart unresponsive container
94           {{- if eq .Values.liveness.enabled true }}
95           livenessProbe:
96             tcpSocket:
97               port: {{ .Values.liveness.port }}
98             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
99             periodSeconds: {{ .Values.liveness.periodSeconds }}
100           {{ end -}}
101           readinessProbe:
102             tcpSocket:
103               port: {{ .Values.readiness.port }}
104             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
105             periodSeconds: {{ .Values.readiness.periodSeconds }}
106           volumeMounts:
107 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
108           - mountPath: /etc/localtime
109             name: localtime
110             readOnly: true
111           - mountPath: /opt/app/policy/pap/etc/mounted
112             name: papconfig-processed
113           resources:
114 {{ include "common.resources" . }}
115         {{- if .Values.nodeSelector }}
116         nodeSelector:
117 {{ toYaml .Values.nodeSelector | indent 10 }}
118         {{- end -}}
119         {{- if .Values.affinity }}
120         affinity:
121 {{ toYaml .Values.affinity | indent 10 }}
122         {{- end }}
123       volumes:
124 {{ include "common.certInitializer.volumes" . | indent 8 }}
125         - name: localtime
126           hostPath:
127              path: /etc/localtime
128         - name: papconfig
129           configMap:
130             name: {{ include "common.fullname" . }}-configmap
131             defaultMode: 0755
132         - name: papconfig-processed
133           emptyDir:
134             medium: Memory
135       imagePullSecrets:
136       - name: "{{ include "common.namespace" . }}-docker-registry-key"