1c66f6ac44530ff04d781241f69c2670f3438565
[oom.git] / kubernetes / policy / components / policy-drools-pdp / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 # Modifications Copyright © 2018-2020, 2022 AT&T Intellectual Property
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 */}}
17
18 apiVersion: apps/v1
19 kind: StatefulSet
20 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
21 spec:
22   selector: {{- include "common.selectors" . | nindent 4 }}
23   serviceName: {{ include "common.servicename" . }}
24   replicas: {{ .Values.replicaCount }}
25   template:
26     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
27     spec:
28       initContainers:
29       - command:
30         - /app/ready.py
31         args:
32         - --job-name
33         - {{ include "common.release" . }}-policy-galera-config
34         env:
35         - name: NAMESPACE
36           valueFrom:
37             fieldRef:
38               apiVersion: v1
39               fieldPath: metadata.namespace
40         image: {{ include "repositoryGenerator.image.readiness" . }}
41         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
42         name: {{ include "common.name" . }}-db-readiness
43         resources:
44           limits:
45             cpu: "100m"
46             memory: "500Mi"
47           requests:
48             cpu: "3m"
49             memory: "20Mi"
50 {{- if not .Values.nexus.offline }}
51       - command:
52         - /app/ready.py
53         args:
54         - --service-name
55         - {{ .Values.nexus.name }}
56         env:
57         - name: NAMESPACE
58           valueFrom:
59             fieldRef:
60               apiVersion: v1
61               fieldPath: metadata.namespace
62         - name: KAFKA_URL
63           value: {{ include "common.release" . }}-{{ .Values.global.kafkaBootstrap }}
64         - name: SASL
65           value: {{ .Values.kafkaUser.authenticationType | upper }}
66         - name: GROUP_ID
67           value: {{ .Values.config.kafka.consumer.groupId }}
68         - name: PAP_TOPIC
69           value: {{ .Values.config.app.listener.policyPdpPapTopic }}
70         image: {{ include "repositoryGenerator.image.readiness" . }}
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         name: {{ include "common.name" . }}-readiness
73         resources:
74           limits:
75             cpu: "100m"
76             memory: "500Mi"
77           requests:
78             cpu: "3m"
79             memory: "20Mi"
80 {{- end }}
81       containers:
82         - name: {{ include "common.name" . }}
83           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
84           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
85           command: ["sh","-c"]
86           args: ["/opt/app/policy/bin/pdpd-cl-entrypoint.sh boot"]
87           ports: {{ include "common.containerPorts" . | nindent 12  }}
88           {{- if eq .Values.liveness.enabled true }}
89           livenessProbe:
90             httpGet:
91               path: /healthcheck/controllers
92               port: 6968
93             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
94             periodSeconds: {{ .Values.liveness.periodSeconds }}
95             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
96           {{- end }}
97           readinessProbe:
98             tcpSocket:
99               port: {{ .Values.service.internalPort }}
100             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
101             periodSeconds: {{ .Values.readiness.periodSeconds }}
102           env:
103           - name: REPLICAS
104             value: "{{ .Values.replicaCount }}"
105           - name: SQL_USER
106             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
107           - name: SQL_PASSWORD
108             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
109           volumeMounts:
110           - mountPath: /etc/localtime
111             name: localtime
112             readOnly: true
113           {{- range $path, $bytes := .Files.Glob "resources/secrets/*" }}
114           - mountPath: /tmp/policy-install/config/{{ base $path }}
115             name: drools-secret
116             subPath: {{ base $path }}
117           {{- end }}
118           {{- range $path, $bytes := .Files.Glob "resources/configmaps/*" }}
119           - mountPath: /tmp/policy-install/config/{{ base $path }}
120             name: drools-config
121             subPath: {{ base $path }}
122           {{- end }}
123           resources: {{ include "common.resources" . | nindent 12 }}
124         {{- if .Values.nodeSelector }}
125         nodeSelector:
126 {{ toYaml .Values.nodeSelector | indent 10 }}
127         {{- end -}}
128         {{- if .Values.affinity }}
129         affinity:
130 {{ toYaml .Values.affinity | indent 10 }}
131         {{- end }}
132       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
133       volumes:
134         - name: localtime
135           hostPath:
136             path: /etc/localtime
137         - name: drools-config
138           configMap:
139             name: {{ include "common.fullname" . }}-configmap
140             items:
141             {{- range $path, $bytes := .Files.Glob "resources/configmaps/*" }}
142             - key: {{ base $path }}
143               path: {{ base $path }}
144               mode: 0755
145             {{- end }}
146         - name: drools-secret
147           secret:
148             secretName: {{ include "common.fullname" . }}-secret
149             items:
150             {{- range $path, $bytes := .Files.Glob "resources/secrets/*" }}
151             - key: {{ base $path }}
152               path: {{ base $path }}
153               mode: 0644
154             {{- end }}
155       {{- include "common.imagePullSecrets" . | nindent 6 }}