Merge "[COMMON] Add custom certs into AAF truststore"
[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:
23   name: {{ include "common.fullname" . }}
24   namespace: {{ include "common.namespace" . }}
25   labels:
26     app: {{ include "common.name" . }}
27     chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
28     release: "{{ include "common.release" . }}"
29     heritage: "{{ .Release.Service }}"
30 spec:
31   replicas: {{ index .Values.replicaCount }}
32   selector: {{- include "common.selectors" . | nindent 4 }}
33   template:
34     metadata:
35       labels: {{- include "common.labels" . | nindent 8 }}
36     spec:
37       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
38       - name: {{ include "common.name" . }}-bootstrap-config
39         image: {{ include "repositoryGenerator.image.envsubst" . }}
40         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
41         command:
42         - sh
43         args:
44         - -c
45         - |
46           export $(cat {{ .Values.certInitializer.credsPath }}/mycreds.prop\
47             | xargs -0)
48           cd /config-input
49           for PFILE in `ls -1`
50           do
51             envsubst <${PFILE} >/config/${PFILE}
52             chmod o+w /config/${PFILE}
53           done
54           cat /config/application.yaml
55         env:
56         - name: A1CONTROLLER_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "login") | indent 10 }}
58         - name: A1CONTROLLER_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "password") | indent 10 }}
60         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
61         - mountPath: /config-input
62           name: {{ include "common.fullname" . }}-policy-conf-input
63         - mountPath: /config
64           name: config
65       containers:
66       - name: {{ include "common.name" . }}-update-config
67         image: "{{ .Values.global.envsubstImage }}"
68         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
69         securityContext:
70           runAsGroup: {{ .Values.groupID }}
71           runAsUser: {{ .Values.userID }}
72           runAsNonRoot: true
73         command:
74         - sh
75         args:
76         - /tmp/scripts/daemon.sh
77         env:
78         - name: A1CONTROLLER_USER
79           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "login") | indent 10 }}
80         - name: A1CONTROLLER_PASSWORD
81           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "password") | indent 10 }}
82         volumeMounts:
83         - mountPath: /tmp/scripts
84           name: {{ include "common.fullname" . }}-envsubst-scripts
85         - mountPath: /config-input
86           name: {{ include "common.fullname" . }}-policy-conf-input
87         - mountPath: /config
88           name: config
89       - name: {{ include "common.name" . }}
90         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
91         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
92         ports: {{ include "common.containerPorts" . | nindent 10  }}
93         readinessProbe:
94           tcpSocket:
95             port: {{ .Values.readiness.port }}
96           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
97           periodSeconds: {{ .Values.liveness.periodSeconds }}
98         livenessProbe:
99           httpGet:
100             path: /status
101             port: {{ .Values.liveness.port }}
102             scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
103           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
104           periodSeconds: {{ .Values.liveness.periodSeconds }}
105         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
106         - name: config
107           mountPath: /opt/app/policy-agent/data/application_configuration.json
108           subPath: application_configuration.json
109         - name: config
110           mountPath: /opt/app/policy-agent/config/application.yaml
111           subPath: application.yaml   
112         - name: vardata
113           mountPath: "/var/policy-management-service/database"
114         resources: {{ include "common.resources" . | nindent 10 }}
115       volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
116         - name: {{ include "common.fullname" . }}-policy-conf-input
117           configMap:
118             name: {{ include "common.fullname" . }}-policy-conf
119         - name: {{ include "common.fullname" . }}-envsubst-scripts
120           configMap:
121             name: {{ include "common.fullname" . }}-envsubst-scripts
122             defaultMode: 0555
123         - name: config
124           emptyDir:
125             medium: Memory
126         - name: vardata
127           persistentVolumeClaim:
128             claimName: {{ include "common.fullname" . }}