Merge "[UUI] Service Mesh Compliance for UUI"
[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 #   Modifications Copyright © 2022 Nordix Foundation
6 #  ================================================================================
7 #  Licensed under the Apache License, Version 2.0 (the "License");
8 #  you may not use this file except in compliance with the License.
9 #  You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #  Unless required by applicable law or agreed to in writing, software
14 #  distributed under the License is distributed on an "AS IS" BASIS,
15 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #  See the License for the specific language governing permissions and
17 #  limitations under the License.
18 #
19 #  SPDX-License-Identifier: Apache-2.0
20 #  ============LICENSE_END=========================================================
21 */}}
22
23 apiVersion: apps/v1
24 kind: StatefulSet
25 metadata:
26   name: {{ include "common.fullname" . }}
27   namespace: {{ include "common.namespace" . }}
28   labels:
29     app: {{ include "common.name" . }}
30     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
31     release: {{ include "common.release" . }}
32     heritage: {{ .Release.Service }}
33 spec:
34   serviceName: {{ include "common.servicename" . }}
35   replicas: {{ .Values.replicaCount }}
36   selector:
37     matchLabels:
38       app: {{ include "common.name" . }}
39   template:
40     metadata:
41       labels:
42         app: {{ include "common.name" . }}
43         release: {{ include "common.release" . }}
44     spec:
45       initContainers:
46       - command:
47         - sh
48         args:
49         - -c
50         - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done"
51         env:
52         - name: TRUSTSTORE_PASSWORD
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "truststore-pass" "key" "password") | indent 10 }}
54         - name: KEYSTORE_PASSWORD
55           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "keystore-pass" "key" "password") | indent 10 }}
56         - name: RESTSERVER_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "login") | indent 10 }}
58         - name: RESTSERVER_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "password") | indent 10 }}
60 {{- if .Values.config.useStrimziKafka }}
61         - name: JAASLOGIN
62           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "policy-kafka-user" "key" "sasl.jaas.config") | indent 10 }}
63 {{- end }}
64         volumeMounts:
65         - mountPath: /config-input
66           name: apexconfig-input
67         - mountPath: /config
68           name: apexconfig
69         image: {{ include "repositoryGenerator.image.envsubst" . }}
70         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
71         name: {{ include "common.name" . }}-update-config
72 {{ include "common.certInitializer.initContainer" . | indent 6 }}
73       containers:
74         - name: {{ include "common.name" . }}
75           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
76           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77           command: ["sh","-c"]
78           args: ["if [ -f {{ .Values.certInitializer.credsPath }}/.ci ]; then \
79                   . {{ .Values.certInitializer.credsPath }}/.ci; fi;\
80                   /opt/app/policy/apex-pdp/bin/apexOnapPf.sh -c /home/apexuser/config/OnapPfConfig.json"]
81           ports:
82           - containerPort: {{ .Values.service.externalPort }}
83           {{- if eq .Values.liveness.enabled true }}
84           livenessProbe:
85             tcpSocket:
86               port: {{ .Values.service.externalPort }}
87             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
88             periodSeconds: {{ .Values.liveness.periodSeconds }}
89           {{- end }}
90           readinessProbe:
91             tcpSocket:
92               port: {{ .Values.service.externalPort }}
93             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
94             periodSeconds: {{ .Values.readiness.periodSeconds }}
95           env:
96           - name: REPLICAS
97             value: "{{ .Values.replicaCount }}"
98 {{- if not .Values.global.aafEnabled }}
99           - name: KEYSTORE_PASSWORD
100             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "keystore-pass" "key" "password") | indent 12 }}
101           - name: TRUSTSTORE_PASSWORD
102             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "truststore-pass" "key" "password") | indent 12 }}
103 {{- end }}
104           volumeMounts:
105 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
106           - mountPath: /etc/localtime
107             name: localtime
108             readOnly: true
109           - mountPath: /var/log/onap
110             name: policy-logs
111           - mountPath: /home/apexuser/config
112             name: apexconfig
113           resources:
114 {{ include "common.resources" . }}
115         {{- if .Values.nodeSelector }}
116         nodeSelector:
117 {{ toYaml .Values.nodeSelector | indent 10 }}
118         {{- end -}}
119         {{- if .Values.affinity }}
120         affinity:
121 {{ toYaml .Values.affinity | indent 10 }}
122         {{- end }}
123       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
124       volumes:
125 {{ include "common.certInitializer.volumes" . | indent 8 }}
126         - name: localtime
127           hostPath:
128             path: /etc/localtime
129         - name: policy-logs
130           emptyDir: {}
131         - name: apexconfig-input
132           configMap:
133             name: {{ include "common.fullname" . }}-configmap
134             defaultMode: 0755
135         - name: apexconfig
136           emptyDir:
137             medium: Memory
138       imagePullSecrets:
139       - name: "{{ include "common.namespace" . }}-docker-registry-key"