4ce90dad1aea947e45dafef1f0cb8fb783b27498
[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 {{- if not .Values.nexus.offline }}
44       - command:
45         - /app/ready.py
46         args:
47         - --container-name
48         - {{ .Values.nexus.name }}
49         env:
50         - name: NAMESPACE
51           valueFrom:
52             fieldRef:
53               apiVersion: v1
54               fieldPath: metadata.namespace
55         image: {{ include "repositoryGenerator.image.readiness" . }}
56         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
57         name: {{ include "common.name" . }}-readiness
58 {{- end }}
59       containers:
60         - name: {{ include "common.name" . }}
61           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
62           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
63           command: ["sh","-c"]
64           args: ["/opt/app/policy/bin/pdpd-cl-entrypoint.sh boot"]
65           ports: {{ include "common.containerPorts" . | nindent 12  }}
66           {{- if eq .Values.liveness.enabled true }}
67           livenessProbe:
68             httpGet:
69               path: /healthcheck/controllers
70               port: 6968
71             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
72             periodSeconds: {{ .Values.liveness.periodSeconds }}
73             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
74           {{- end }}
75           readinessProbe:
76             tcpSocket:
77               port: {{ .Values.service.internalPort }}
78             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
79             periodSeconds: {{ .Values.readiness.periodSeconds }}
80           env:
81           - name: REPLICAS
82             value: "{{ .Values.replicaCount }}"
83           - name: SQL_USER
84             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
85           - name: SQL_PASSWORD
86             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
87           volumeMounts:
88           - mountPath: /etc/localtime
89             name: localtime
90             readOnly: true
91           {{- range $path, $bytes := .Files.Glob "resources/secrets/*" }}
92           - mountPath: /tmp/policy-install/config/{{ base $path }}
93             name: drools-secret
94             subPath: {{ base $path }}
95           {{- end }}
96           {{- range $path, $bytes := .Files.Glob "resources/configmaps/*" }}
97           - mountPath: /tmp/policy-install/config/{{ base $path }}
98             name: drools-config
99             subPath: {{ base $path }}
100           {{- end }}
101           resources: {{ include "common.resources" . | nindent 12 }}
102         {{- if .Values.nodeSelector }}
103         nodeSelector:
104 {{ toYaml .Values.nodeSelector | indent 10 }}
105         {{- end -}}
106         {{- if .Values.affinity }}
107         affinity:
108 {{ toYaml .Values.affinity | indent 10 }}
109         {{- end }}
110       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
111       volumes:
112         - name: localtime
113           hostPath:
114             path: /etc/localtime
115         - name: drools-config
116           configMap:
117             name: {{ include "common.fullname" . }}-configmap
118             items:
119             {{- range $path, $bytes := .Files.Glob "resources/configmaps/*" }}
120             - key: {{ base $path }}
121               path: {{ base $path }}
122               mode: 0755
123             {{- end }}
124         - name: drools-secret
125           secret:
126             secretName: {{ include "common.fullname" . }}-secret
127             items:
128             {{- range $path, $bytes := .Files.Glob "resources/secrets/*" }}
129             - key: {{ base $path }}
130               path: {{ base $path }}
131               mode: 0644
132             {{- end }}
133       imagePullSecrets:
134       - name: "{{ include "common.namespace" . }}-docker-registry-key"