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