Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / policy / components / policy-gui / templates / deployment.yaml
1 {{/*
2 #  ============LICENSE_START=======================================================
3 #   Copyright (C) 2021-2022 Nordix Foundation.
4 #  ================================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #
17 #  SPDX-License-Identifier: Apache-2.0
18 #  ============LICENSE_END=========================================================
19 */}}
20
21 apiVersion: apps/v1
22 kind: Deployment
23 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
24 spec:
25   selector: {{- include "common.selectors" . | nindent 4 }}
26   replicas: {{ .Values.replicaCount }}
27   template:
28     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
29     spec:
30       initContainers:
31       - command:
32           - sh
33         args:
34           - -c
35           - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done"
36         env:
37         - name: POLICY_LOGS
38           value: {{ .Values.log.path }}
39         volumeMounts:
40           - mountPath: /config-input
41             name: policy-gui-config
42           - mountPath: /config
43             name: policy-gui-config-processed
44         image: {{ include "repositoryGenerator.image.envsubst" . }}
45         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
46         name: {{ include "common.name" . }}-update-config
47       - command:
48         - /app/ready.py
49         args:
50         - --service-name
51         - policy-clamp-runtime-acm
52         env:
53         - name: NAMESPACE
54           valueFrom:
55             fieldRef:
56               apiVersion: v1
57               fieldPath: metadata.namespace
58         image: {{ include "repositoryGenerator.image.readiness" . }}
59         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
60         name: {{ include "common.name" . }}-readiness
61         resources:
62           limits:
63             cpu: "100m"
64             memory: "500Mi"
65           requests:
66             cpu: "3m"
67             memory: "20Mi"
68       containers:
69         # side car containers
70         {{ if .Values.global.centralizedLoggingEnabled }}{{ include "common.log.sidecar" . | nindent 8 }}{{ end }}
71         # main container
72         - name: {{ include "common.name" . }}
73           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
74           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
75           command: ["/opt/app/policy/gui/bin/policy-gui.sh"]
76           env:
77           - name: CLAMP_URL
78             value: http://policy-clamp-runtime-acm:6969
79           ports: {{ include "common.containerPorts" . | nindent 12  }}
80           # disable liveness probe when breakpoints set in debugger
81           # so K8s doesn't restart unresponsive container
82           {{- if eq .Values.liveness.enabled true }}
83           livenessProbe:
84             tcpSocket:
85               port: {{ .Values.service.internalPort }}
86             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
87             periodSeconds: {{ .Values.liveness.periodSeconds }}
88           {{ end -}}
89           readinessProbe:
90             tcpSocket:
91               port: {{ .Values.service.internalPort }}
92             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
93             periodSeconds: {{ .Values.readiness.periodSeconds }}
94           volumeMounts:
95           - name: logs
96             mountPath: {{ .Values.log.path }}
97           - mountPath: /opt/app/policy/gui/etc/application.yml
98             name: policy-gui-config-processed
99             subPath: application.yml
100           - mountPath: /opt/app/policy/gui/etc/logback.xml
101             name: policy-gui-config-processed
102             subPath: logback.xml
103           resources: {{ include "common.resources" . | nindent 12 }}
104         {{- if .Values.nodeSelector }}
105         nodeSelector:
106 {{ toYaml .Values.nodeSelector | indent 10 }}
107         {{- end -}}
108         {{- if .Values.affinity }}
109         affinity:
110 {{ toYaml .Values.affinity | indent 10 }}
111         {{- end }}
112       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
113       volumes:
114         - name: {{ include "common.fullname" . }}-config
115           configMap:
116             name: {{ include "common.fullname" . }}
117         - name:  logs
118           emptyDir: {}
119         {{ if .Values.global.centralizedLoggingEnabled }}{{ include "common.log.volumes" . | nindent 8 }}{{ end }}
120         - name: policy-gui-config
121           configMap:
122             name: {{ include "common.fullname" . }}-configmap
123             defaultMode: 0755
124         - name: policy-gui-config-processed
125           emptyDir:
126             medium: Memory
127       {{- include "common.imagePullSecrets" . | nindent 6 }}