Merge "[UUI] Service Mesh Compliance for UUI"
[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:
24   name: {{ include "common.fullname" . }}
25   namespace: {{ include "common.namespace" . }}
26   labels:
27     app: {{ include "common.name" . }}
28     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
29     release: {{ include "common.release" . }}
30     heritage: {{ .Release.Service }}
31 spec:
32   replicas: {{ .Values.replicaCount }}
33   selector:
34     matchLabels:
35       app: {{ include "common.name" . }}
36   template:
37     metadata:
38       labels:
39         app: {{ include "common.name" . }}
40         release: {{ include "common.release" . }}
41     spec:
42       initContainers:
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: KEYSTORE
50           value: {{ .Values.certStores.keystoreLocation }}
51         - name: KEYSTORE_PASSWD
52           value: {{ .Values.certStores.keyStorePassword }}
53         - name: TRUSTSTORE
54           value: {{ .Values.certStores.truststoreLocation }}
55         - name: TRUSTSTORE_PASSWD
56           value: {{ .Values.certStores.trustStorePassword }}
57         - name: POLICY_LOGS
58           value: {{ .Values.log.path }}
59         volumeMounts:
60           - mountPath: /config-input
61             name: policy-gui-config
62           - mountPath: /config
63             name: policy-gui-config-processed
64         image: {{ include "repositoryGenerator.image.envsubst" . }}
65         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
66         name: {{ include "common.name" . }}-update-config
67       - command:
68         - /app/ready.py
69         args:
70         - --container-name
71         - policy-clamp-runtime-acm
72         env:
73         - name: NAMESPACE
74           valueFrom:
75             fieldRef:
76               apiVersion: v1
77               fieldPath: metadata.namespace
78         image: {{ include "repositoryGenerator.image.readiness" . }}
79         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
80         name: {{ include "common.name" . }}-readiness
81 {{ include "common.certInitializer.initContainer" . | nindent 6 }}
82       containers:
83         # side car containers
84         {{ if .Values.global.centralizedLoggingEnabled }}{{ include "common.log.sidecar" . | nindent 8 }}{{ end }}
85         # main container
86         - name: {{ include "common.name" . }}
87           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
88           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
89 {{- if not (include "common.onServiceMesh" .)  }}
90           command: ["sh","-c"]
91           args: ["source {{ .Values.certInitializer.credsPath }}/.ci;/opt/app/policy/gui/bin/policy-gui.sh"]
92           env:
93 {{ else }}
94           command: ["/opt/app/policy/gui/bin/policy-gui.sh"]
95           env:
96           - name: KEYSTORE_PASSWD
97             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "keystore-password" "key" "password") | indent 12 }}
98           - name: TRUSTSTORE_PASSWD
99             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "truststore-password" "key" "password") | indent 12 }}
100 {{ end }}
101           - name: CLAMP_URL
102             value: http://policy-clamp-runtime-acm:6969
103           ports:
104           - containerPort: {{ .Values.service.internalPort }}
105           # disable liveness probe when breakpoints set in debugger
106           # so K8s doesn't restart unresponsive container
107           {{- if eq .Values.liveness.enabled true }}
108           livenessProbe:
109             tcpSocket:
110               port: {{ .Values.service.internalPort }}
111             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
112             periodSeconds: {{ .Values.liveness.periodSeconds }}
113           {{ end -}}
114           readinessProbe:
115             tcpSocket:
116               port: {{ .Values.service.internalPort }}
117             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
118             periodSeconds: {{ .Values.readiness.periodSeconds }}
119           volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
120           - name: logs
121             mountPath: {{ .Values.log.path }}
122           - mountPath: /opt/app/policy/gui/etc/application.yml
123             name: policy-gui-config-processed
124             subPath: application.yml
125           - mountPath: /opt/app/policy/gui/etc/logback.xml
126             name: policy-gui-config-processed
127             subPath: logback.xml
128           resources:
129 {{ include "common.resources" . | indent 12 }}
130         {{- if .Values.nodeSelector }}
131         nodeSelector:
132 {{ toYaml .Values.nodeSelector | indent 10 }}
133         {{- end -}}
134         {{- if .Values.affinity }}
135         affinity:
136 {{ toYaml .Values.affinity | indent 10 }}
137         {{- end }}
138       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
139       volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
140         - name: {{ include "common.fullname" . }}-config
141           configMap:
142             name: {{ include "common.fullname" . }}
143         - name:  logs
144           emptyDir: {}
145         {{ if .Values.global.centralizedLoggingEnabled }}{{ include "common.log.volumes" . | nindent 8 }}{{ end }}
146         - name: policy-gui-config
147           configMap:
148             name: {{ include "common.fullname" . }}-configmap
149             defaultMode: 0755
150         - name: policy-gui-config-processed
151           emptyDir:
152             medium: Memory
153       imagePullSecrets:
154       - name: "{{ include "common.namespace" . }}-docker-registry-key"