Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / policy / components / policy-apex-pdp / templates / statefulset.yaml
1 {{/*
2 #  ============LICENSE_START=======================================================
3 #   Copyright (C) 2018 Ericsson. All rights reserved.
4 #   Modifications Copyright (C) 2020 AT&T Intellectual Property.
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 #  SPDX-License-Identifier: Apache-2.0
19 #  ============LICENSE_END=========================================================
20 */}}
21
22 apiVersion: apps/v1
23 kind: StatefulSet
24 metadata:
25   name: {{ include "common.fullname" . }}
26   namespace: {{ include "common.namespace" . }}
27   labels:
28     app: {{ include "common.name" . }}
29     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
30     release: {{ include "common.release" . }}
31     heritage: {{ .Release.Service }}
32 spec:
33   serviceName: {{ include "common.servicename" . }}
34   replicas: {{ .Values.replicaCount }}
35   selector:
36     matchLabels:
37       app: {{ include "common.name" . }}
38   template:
39     metadata:
40       labels:
41         app: {{ include "common.name" . }}
42         release: {{ include "common.release" . }}
43     spec:
44       initContainers:
45       - command:
46         - sh
47         args:
48         - -c
49         - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done"
50         env:
51         - name: TRUSTSTORE_PASSWORD
52           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "truststore-pass" "key" "password") | indent 10 }}
53         - name: KEYSTORE_PASSWORD
54           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "keystore-pass" "key" "password") | indent 10 }}
55         - name: RESTSERVER_USER
56           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "login") | indent 10 }}
57         - name: RESTSERVER_PASSWORD
58           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "password") | indent 10 }}
59         volumeMounts:
60         - mountPath: /config-input
61           name: apexconfig-input
62         - mountPath: /config
63           name: apexconfig
64         image: {{ include "repositoryGenerator.image.envsubst" . }}
65         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
66         name: {{ include "common.name" . }}-update-config
67 {{ include "common.certInitializer.initContainer" . | indent 6 }}
68       containers:
69         - name: {{ include "common.name" . }}
70           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
71           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72           command: ["sh","-c"]
73           args: ["if [ -f {{ .Values.certInitializer.credsPath }}/.ci ]; then \
74                   . {{ .Values.certInitializer.credsPath }}/.ci; fi;\
75                   /opt/app/policy/apex-pdp/bin/apexOnapPf.sh -c /home/apexuser/config/OnapPfConfig.json"]
76           ports:
77           - containerPort: {{ .Values.service.externalPort }}
78           {{- if eq .Values.liveness.enabled true }}
79           livenessProbe:
80             tcpSocket:
81               port: {{ .Values.service.externalPort }}
82             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
83             periodSeconds: {{ .Values.liveness.periodSeconds }}
84           {{- end }}
85           readinessProbe:
86             tcpSocket:
87               port: {{ .Values.service.externalPort }}
88             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
89             periodSeconds: {{ .Values.readiness.periodSeconds }}
90           env:
91           - name: REPLICAS
92             value: "{{ .Values.replicaCount }}"
93 {{- if not .Values.global.aafEnabled }}
94           - name: KEYSTORE_PASSWORD
95             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "keystore-pass" "key" "password") | indent 12 }}
96           - name: TRUSTSTORE_PASSWORD
97             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "truststore-pass" "key" "password") | indent 12 }}
98 {{- end }}
99           volumeMounts:
100 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
101           - mountPath: /etc/localtime
102             name: localtime
103             readOnly: true
104           - mountPath: /var/log/onap
105             name: policy-logs
106           - mountPath: /home/apexuser/config
107             name: apexconfig
108           resources:
109 {{ include "common.resources" . }}
110         {{- if .Values.nodeSelector }}
111         nodeSelector:
112 {{ toYaml .Values.nodeSelector | indent 10 }}
113         {{- end -}}
114         {{- if .Values.affinity }}
115         affinity:
116 {{ toYaml .Values.affinity | indent 10 }}
117         {{- end }}
118       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
119       volumes:
120 {{ include "common.certInitializer.volumes" . | indent 8 }}
121         - name: localtime
122           hostPath:
123             path: /etc/localtime
124         - name: policy-logs
125           emptyDir: {}
126         - name: apexconfig-input
127           configMap:
128             name: {{ include "common.fullname" . }}-configmap
129             defaultMode: 0755
130         - name: apexconfig
131           emptyDir:
132             medium: Memory
133       imagePullSecrets:
134       - name: "{{ include "common.namespace" . }}-docker-registry-key"