[COMMON] Harmonize resource settings
[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 {{- if not .Values.global.useStrimziKafkaPf }}
33 {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
34 {{- end }}
35       - command:
36         - /app/ready.py
37         args:
38         - --job-name
39 {{ if not .Values.global.postgres.localCluster }}
40         - {{ include "common.release" . }}-policy-galera-config
41 {{ else }}
42         - {{ include "common.release" . }}-policy-pg-config
43 {{ end }}        env:
44         - name: NAMESPACE
45           valueFrom:
46             fieldRef:
47               apiVersion: v1
48               fieldPath: metadata.namespace
49         image: {{ include "repositoryGenerator.image.readiness" . }}
50         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
51         name: {{ include "common.name" . }}-db-readiness
52         resources:
53           limits:
54             cpu: "100m"
55             memory: "0.5Gi"
56           requests:
57             cpu: "3m"
58             memory: "0.02Gi"
59       - command:
60         - sh
61         args:
62         - -c
63         - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done"
64         env:
65         - name: SQL_USER
66           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
67         - name: SQL_PASSWORD
68           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
69         - name: RESTSERVER_USER
70           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-secret" "key" "login") | indent 10 }}
71         - name: RESTSERVER_PASSWORD
72           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-secret" "key" "password") | indent 10 }}
73         - name: API_USER
74           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-secret" "key" "login") | indent 10 }}
75         - name: API_PASSWORD
76           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-secret" "key" "password") | indent 10 }}
77         - name: DISTRIBUTION_USER
78           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "distribution-secret" "key" "login") | indent 10 }}
79         - name: DISTRIBUTION_PASSWORD
80           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "distribution-secret" "key" "password") | indent 10 }}
81 {{- if .Values.global.useStrimziKafkaPf }}
82         - name: JAASLOGIN
83           valueFrom:
84             secretKeyRef:
85               name: {{ include "common.name" . }}-ku
86               key: sasl.jaas.config
87 {{- end }}
88         volumeMounts:
89         - mountPath: /config-input
90           name: papconfig
91         - mountPath: /config
92           name: papconfig-processed
93         image: {{ include "repositoryGenerator.image.envsubst" . }}
94         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
95         name: {{ include "common.name" . }}-update-config
96       containers:
97         - name: {{ include "common.name" . }}
98           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
99           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
100
101           command: [ "/bin/sh", "-cx" ]
102           args:
103             - cat /opt/app/policy/pap/etc/mounted/papParameters.yaml;
104               /opt/app/policy/pap/bin/policy-pap.sh /opt/app/policy/pap/etc/mounted/papParameters.yaml
105           ports: {{ include "common.containerPorts" . | nindent 12  }}
106           # disable liveness probe when breakpoints set in debugger
107           # so K8s doesn't restart unresponsive container
108           {{- if eq .Values.liveness.enabled true }}
109           livenessProbe:
110             tcpSocket:
111               port: {{ .Values.liveness.port }}
112             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
113             periodSeconds: {{ .Values.liveness.periodSeconds }}
114           {{ end -}}
115           readinessProbe:
116             httpGet:
117               path: {{ .Values.readiness.api }}
118               port: {{ .Values.readiness.port }}
119               httpHeaders:
120                 - name: Authorization
121                   value: Basic {{ printf "%s:%s" .Values.restServer.user .Values.restServer.password | b64enc }}
122               scheme: "HTTP"
123             successThreshold: {{ .Values.readiness.successThreshold }}
124             failureThreshold: {{ .Values.readiness.failureThreshold }}
125             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
126             periodSeconds: {{ .Values.readiness.periodSeconds }}
127             timeoutSeconds: {{ .Values.readiness.timeout }}
128           volumeMounts:
129           - mountPath: /etc/localtime
130             name: localtime
131             readOnly: true
132           - mountPath: /opt/app/policy/pap/etc/mounted
133             name: papconfig-processed
134           resources: {{ include "common.resources" . | nindent 12 }}
135         {{- if .Values.nodeSelector }}
136         nodeSelector:
137 {{ toYaml .Values.nodeSelector | indent 10 }}
138         {{- end -}}
139         {{- if .Values.affinity }}
140         affinity:
141 {{ toYaml .Values.affinity | indent 10 }}
142         {{- end }}
143       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
144       volumes:
145         - name: localtime
146           hostPath:
147              path: /etc/localtime
148         - name: papconfig
149           configMap:
150             name: {{ include "common.fullname" . }}-configmap
151             defaultMode: 0755
152         - name: papconfig-processed
153           emptyDir:
154             medium: Memory
155       imagePullSecrets:
156       - name: "{{ include "common.namespace" . }}-docker-registry-key"