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