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