e2463aa2c2eb91ee7644932be2952c1a8d63d25f
[oom.git] / kubernetes / policy / charts / drools / templates / statefulset.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 # Modifications Copyright © 2018-2019 AT&T
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 apiVersion: apps/v1beta1
17 kind: StatefulSet
18 metadata:
19   name: {{ include "common.fullname" . }}
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ include "common.release" . }}
25     heritage: {{ .Release.Service }}
26 spec:
27   serviceName: {{ include "common.servicename" . }}
28   replicas: {{ .Values.replicaCount }}
29   selector:
30     matchLabels:
31       app: {{ include "common.name" . }}
32   template:
33     metadata:
34       labels:
35         app: {{ include "common.name" . }}
36         release: {{ include "common.release" . }}
37     spec:
38       initContainers:
39       - command:
40         - /root/ready.py
41         args:
42         - --container-name
43         - {{ include "common.release" . }}-galera-config
44         - --container-name
45         - {{ .Values.global.nexus.nameOverride }}
46         env:
47         - name: NAMESPACE
48           valueFrom:
49             fieldRef:
50               apiVersion: v1
51               fieldPath: metadata.namespace
52         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
53         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
54         name: {{ include "common.name" . }}-readiness
55       containers:
56         - name: {{ include "common.name" . }}
57           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
58           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59           ports:
60           - containerPort: {{ .Values.service.externalPort }}
61           - containerPort: {{ .Values.service.externalPort2 }}
62           {{- if eq .Values.liveness.enabled true }}
63           livenessProbe:
64             tcpSocket:
65               port: {{ .Values.service.externalPort }}
66             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
67             periodSeconds: {{ .Values.liveness.periodSeconds }}
68           {{- end }}
69           readinessProbe:
70             tcpSocket:
71               port: {{ .Values.service.externalPort }}
72             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
73             periodSeconds: {{ .Values.readiness.periodSeconds }}
74           env:
75           - name: REPLICAS
76             value: "{{ .Values.replicaCount }}"
77           - name: SQL_USER
78             {{- include "common.secret.envFromSecret" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
79           - name: SQL_PASSWORD
80             {{- include "common.secret.envFromSecret" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
81           volumeMounts:
82           - mountPath: /etc/localtime
83             name: localtime
84             readOnly: true
85           {{- range $path, $bytes := .Files.Glob "resources/secrets/*" }}
86           - mountPath: /tmp/policy-install/config/{{ base $path }}
87             name: drools-secret
88             subPath: {{ base $path }}
89           {{- end }}
90           {{- range $path, $bytes := .Files.Glob "resources/configmaps/*" }}
91           - mountPath: /tmp/policy-install/config/{{ base $path }}
92             name: drools-config
93             subPath: {{ base $path }}
94           {{- end }}
95           - mountPath: /var/log/onap
96             name: policy-logs
97           resources:
98 {{ include "common.resources" . | indent 12 }}
99         {{- if .Values.nodeSelector }}
100         - image: "{{ .Values.global.loggingRepository | default .Values.loggingRepository }}/{{ .Values.loggingImage }}"
101           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
102           name: filebeat-onap
103           volumeMounts:
104           - mountPath: /usr/share/filebeat/filebeat.yml
105             name: filebeat-conf
106             subPath: filebeat.yml
107           - mountPath: /var/log/onap
108             name: policy-logs
109           - mountPath: /usr/share/filebeat/data
110             name: policy-data-filebeat
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       volumes:
119         - name: localtime
120           hostPath:
121             path: /etc/localtime
122         - name: filebeat-conf
123           configMap:
124             name: {{ include "common.release" . }}-filebeat-configmap
125         - name: policy-logs
126           emptyDir: {}
127         - name: policy-data-filebeat
128           emptyDir: {}
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"