Merge "[DCAEMOD] Uses new tpls for repos / images"
[oom.git] / kubernetes / a1policymanagement / templates / deployment.yaml
1 {{/*
2 ################################################################################
3 #   Copyright (c) 2020 Nordix Foundation.                                      #
4 #   Copyright © 2020 Samsung Electronics, Modifications                        #
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 */}}
19
20 kind: Deployment
21 apiVersion: apps/v1
22 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
23 spec:
24   replicas: {{ index .Values.replicaCount }}
25   selector: {{- include "common.selectors" . | nindent 4 }}
26   template:
27     metadata:
28       labels: {{- include "common.labels" . | nindent 8 }}
29     spec:
30       initContainers:
31       - name: {{ include "common.name" . }}-bootstrap-config
32         image: {{ include "repositoryGenerator.image.envsubst" . }}
33         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
34         command:
35         - sh
36         args:
37         - -c
38         - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; chmod o+w /config/${PFILE}; done"
39         env:
40         - name: A1CONTROLLER_USER
41           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "login") | indent 10 }}
42         - name: A1CONTROLLER_PASSWORD
43           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "password") | indent 10 }}
44         volumeMounts:
45         - mountPath: /config-input
46           name: {{ include "common.fullname" . }}-policy-conf-input
47         - mountPath: /config
48           name: config
49       containers:
50       - name: {{ include "common.name" . }}-update-config
51         image: "{{ .Values.global.envsubstImage }}"
52         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
53         securityContext:
54           runAsGroup: {{ .Values.groupID }}
55           runAsUser: {{ .Values.userID }}
56           runAsNonRoot: true
57         command:
58         - sh
59         args:
60         - /tmp/scripts/daemon.sh
61         env:
62         - name: A1CONTROLLER_USER
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "login") | indent 10 }}
64         - name: A1CONTROLLER_PASSWORD
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "password") | indent 10 }}
66         volumeMounts:
67         - mountPath: /tmp/scripts
68           name: {{ include "common.fullname" . }}-envsubst-scripts
69         - mountPath: /config-input
70           name: {{ include "common.fullname" . }}-policy-conf-input
71         - mountPath: /config
72           name: config
73       - name: {{ include "common.name" . }}
74         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
75         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
76         ports: {{ include "common.containerPorts" . | nindent 10  }}
77         readinessProbe:
78           tcpSocket:
79             port: {{ .Values.readiness.port }}
80           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
81           periodSeconds: {{ .Values.liveness.periodSeconds }}
82         livenessProbe:
83           httpGet:
84             path: /status
85             port: {{ .Values.liveness.port }}
86             scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
87           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
88           periodSeconds: {{ .Values.liveness.periodSeconds }}
89         volumeMounts:
90         - name: config
91           mountPath: /opt/app/policy-agent/data
92         resources: {{ include "common.resources" . | nindent 10 }}
93       volumes:
94         - name: {{ include "common.fullname" . }}-policy-conf-input
95           configMap:
96             name: {{ include "common.fullname" . }}-policy-conf
97             defaultMode: 0555
98         - name: {{ include "common.fullname" . }}-envsubst-scripts
99           configMap:
100             name: {{ include "common.fullname" . }}-envsubst-scripts
101         - name: config
102           emptyDir:
103             medium: Memory