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