2659e96a91d5dc988540eaf58589b78131bdde67
[oom.git] / kubernetes / dmaap / components / dmaap-dr-node / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
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/v1
17 kind: StatefulSet
18 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
19 spec:
20   selector: {{- include "common.selectors" . | nindent 4 }}
21   serviceName: {{ include "common.servicename" . }}
22   replicas: {{ .Values.replicaCount }}
23   template:
24     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
25     spec:
26       {{ include "common.podSecurityContext" . | indent 6 | trim}}
27       initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 8 }}
28         - name: {{ include "common.name" . }}-permission-fixer
29           securityContext:
30             runAsUser: 0
31           image: {{ include "repositoryGenerator.image.busybox" . }}
32           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
33           command: ["chown","-Rf","1000:1001", "/opt/app/"]
34           volumeMounts:
35             - name: {{ include "common.fullname" . }}-spool
36               mountPath: {{ .Values.persistence.spool.path }}
37             - name: {{ include "common.fullname" . }}-event-logs
38               mountPath: {{ .Values.persistence.event.path }}
39       containers:
40         - name: {{ include "common.name" . }}
41           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
42           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
43           ports: {{ include "common.containerPorts" . | nindent 12  }}
44           {{- if eq .Values.liveness.enabled true }}
45           livenessProbe:
46             tcpSocket:
47               port: {{.Values.liveness.port}}
48             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
49             periodSeconds: {{ .Values.liveness.periodSeconds }}
50           {{ end -}}
51           readinessProbe:
52             tcpSocket:
53               port: {{.Values.readiness.port}}
54             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
55             periodSeconds: {{ .Values.readiness.periodSeconds }}
56           volumeMounts:
57             - mountPath: {{ .Values.persistence.spool.path }}
58               name: {{ include "common.fullname" . }}-spool
59             - mountPath: {{ .Values.persistence.event.path }}
60               name: {{ include "common.fullname" . }}-event-logs
61             - mountPath: /etc/localtime
62               name: localtime
63               readOnly: false
64             - mountPath: /opt/app/datartr/etc/node.properties
65               name: {{ include "common.fullname" . }}-config
66               subPath: node.properties
67             - mountPath: /opt/app/datartr/etc/logback.xml
68               name: {{ include "common.fullname" . }}-log-conf
69               subPath: logback.xml
70           resources: {{ include "common.resources" . | nindent 12 }}
71         {{- if .Values.nodeSelector }}
72         nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
73         {{- end -}}
74         {{- if .Values.affinity }}
75         affinity: {{ toYaml .Values.affinity | nindent 10 }}
76         {{- end }}
77       {{- include "common.imagePullSecrets" . | nindent 6 }}
78       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
79       volumes:
80         - name: localtime
81           hostPath:
82             path: /etc/localtime
83         - name: {{ include "common.fullname" . }}-config
84           configMap:
85             name: {{ include "common.fullname" . }}-node-props
86             items:
87             - key: node.properties
88               path: node.properties
89         - name: {{ include "common.fullname" . }}-log-conf
90           configMap:
91             name: {{ include "common.fullname" . }}-log
92       {{- if not .Values.persistence.enabled }}
93         - name:  {{ include "common.fullname" . }}-event-logs
94           emptyDir: {}
95         - name: {{ include "common.fullname" . }}-spool
96           emptyDir: {}
97       {{- end }}
98 {{- if .Values.persistence.enabled }}
99   volumeClaimTemplates:
100   - {{ include "common.PVCTemplate" (dict "dot" . "suffix" "spool" "persistenceInfos" .Values.persistence.spool) | indent 4 | trim }}
101   - {{ include "common.PVCTemplate" (dict "dot" . "suffix" "event-logs" "persistenceInfos" .Values.persistence.event) | indent 4 | trim }}
102 {{- end }}