d4ac832e093dd04d3509b8904e581e4d15faa188
[oom.git] / kubernetes / dcaegen2 / components / dcae-redis / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, AT&T, 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:
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: {{ .Values.service.name }}
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       containers:
40         - name: {{ include "common.name" . }}
41           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
42           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
43           command:
44           - /bin/sh
45           - -c
46           - |
47             /opt/scripts/redis-cluster-config.sh
48           ports:
49           - containerPort: {{ .Values.service.internalPort }}
50             name: {{ .Values.service.name }}
51           - containerPort: {{ .Values.service.internalPort2 }}
52             name: {{ .Values.service.name2 }}
53           # disable liveness probe when breakpoints set in debugger
54           # so K8s doesn't restart unresponsive container
55           {{- if eq .Values.liveness.enabled true }}
56           livenessProbe:
57             exec:
58               command:
59               - sh
60               - -c
61               - "redis-cli -h $(hostname) ping"
62             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
63             periodSeconds: {{ .Values.liveness.periodSeconds }}
64             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
65           {{end -}}
66           readinessProbe:
67             tcpSocket:
68               port: {{ .Values.service.internalPort }}
69             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
70             periodSeconds: {{ .Values.readiness.periodSeconds }}
71           env:
72           volumeMounts:
73           - mountPath: /etc/localtime
74             name: localtime
75             readOnly: true
76           - mountPath: /conf
77             name: {{ include "common.fullname" . }}-config
78           - mountPath: /data
79             name: {{ include "common.fullname" . }}-data
80           - mountPath: /opt/scripts
81             name: {{ include "common.fullname" . }}-scripts
82           resources:
83 {{ include "common.resources" . | indent 12 }}
84         {{- if .Values.nodeSelector }}
85         nodeSelector:
86 {{ toYaml .Values.nodeSelector | indent 10 }}
87         {{- end -}}
88         {{- if .Values.affinity }}
89         affinity:
90 {{ toYaml .Values.affinity | indent 10 }}
91         {{- end }}
92       volumes:
93       - name: {{ include "common.fullname" . }}-config
94         configMap:
95           name: {{ include "common.fullname" . }}
96           items:
97           - key: redis.conf
98             path: redis.conf
99       - name: {{ include "common.fullname" . }}-scripts
100         configMap:
101           name: {{ include "common.fullname" . }}-scripts
102           defaultMode: 0755
103       - name: localtime
104         hostPath:
105           path: /etc/localtime
106       {{- if not .Values.persistence.enabled }}
107       - name: {{ include "common.fullname" . }}-data
108         emptyDir: {}
109       {{- end }}
110       imagePullSecrets:
111       - name: "{{ include "common.namespace" . }}-docker-registry-key"
112   {{- if .Values.persistence.enabled }}
113   volumeClaimTemplates:
114   - metadata:
115       name: {{ include "common.fullname" . }}-data
116       labels:
117         name: {{ include "common.fullname" . }}
118     spec:
119       accessModes:
120       - {{ .Values.persistence.accessMode | quote }}
121       storageClassName: {{ include "common.storageClass" . }}
122       resources:
123         requests:
124           storage: {{ .Values.persistence.size | quote}}
125   {{- end }}