Merge "Update ves collector image"
[oom.git] / kubernetes / common / cassandra / templates / statefulset.yaml
1 # Copyright © 2018 Amdocs, AT&T, Bell Canada
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 apiVersion: apps/v1beta1
16 kind: StatefulSet
17 metadata:
18   name: {{ include "common.fullname" . }}
19   namespace: {{ include "common.namespace" . }}
20   labels:
21     app: {{ include "common.name" . }}
22     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23     release: {{ include "common.release" . }}
24     heritage: {{ .Release.Service }}
25 spec:
26   selector:
27     matchLabels:
28       app: {{ include  "common.name" . }}
29       release: {{ include "common.release" . }}
30   serviceName: {{ include "common.servicename" . }}
31   replicas: {{ .Values.replicaCount }}
32   podManagementPolicy: {{ .Values.podManagementPolicy }}
33   updateStrategy:
34     type: {{ .Values.updateStrategy.type }}
35   template:
36     metadata:
37       labels:
38         app: {{ include "common.name" . }}
39         release: {{ include "common.release" . }}
40       name: {{ include "common.name" . }}
41     spec:
42       hostNetwork: {{ .Values.hostNetwork }}
43       containers:
44       - name: {{ include "common.name" . }}
45         image: {{ .Values.image }}
46         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
47         ports:
48         {{- range $index, $ports := .Values.service.ports }}
49         - containerPort: {{ $ports.port }}
50         {{- end }}
51         volumeMounts:
52           - name: {{ include "common.fullname" . }}-data
53             mountPath: /var/lib/cassandra
54           - name: localtime
55             mountPath: /etc/localtime
56             readOnly: true
57           - name: cassandra-entrypoint
58             mountPath: /docker-entrypoint.sh
59             subPath: docker-entrypoint.sh
60           {{- range $key, $value := .Values.configOverrides }}
61           - name: cassandra-config-{{ $key | replace "." "-" }}
62             mountPath: /etc/cassandra/{{ $key }}
63             subPath: {{ $key }}
64           {{- end }}
65         {{- if eq .Values.liveness.enabled true }}
66         livenessProbe:
67           exec:
68            command:
69             - /bin/bash
70             - -c
71             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
72           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
73           periodSeconds: {{ .Values.liveness.periodSeconds }}
74           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
75           successThreshold: {{ .Values.liveness.successThreshold }}
76           failureThreshold: {{ .Values.liveness.failureThreshold }}
77         {{ end }}
78         readinessProbe:
79           exec:
80             command:
81             - /bin/bash
82             - -c
83             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
84           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
85           periodSeconds: {{ .Values.readiness.periodSeconds }}
86           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
87           successThreshold: {{ .Values.readiness.successThreshold }}
88           failureThreshold: {{ .Values.readiness.failureThreshold }}
89         env:
90           {{- $seed_size := default 1 .Values.replicaCount | int -}}
91           {{- $global := . }}
92           - name: CASSANDRA_SEEDS
93           {{- if .Values.hostNetwork }}
94             value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
95           {{- else }}
96             value: "{{- range $i, $e := until $seed_size }}{{ template "common.fullname" $global }}-{{ $i }}.{{ template "common.servicename" $global }}.{{ $global.Release.Namespace }}.svc.{{ $global.Values.config.cluster_domain }}{{- if (lt ( add1 $i ) $seed_size ) }},{{- end }}{{- end }}"
97           {{- end }}
98           - name: MAX_HEAP_SIZE
99             value: {{ .Values.config.heap.max }}
100           - name: HEAP_NEWSIZE
101             value: {{ .Values.config.heap.min }}
102           - name: JVM_OPTS
103             value: {{ .Values.config.jvmOpts | quote }}
104           - name: CASSANDRA_CLUSTER_NAME
105             value: {{ .Values.config.clusterName | quote }}
106           - name: CASSANDRA_DC
107             value: {{ .Values.config.dataCenter | quote }}
108           - name: CASSANDRA_RACK
109             value: {{ .Values.config.rackName | quote }}
110           - name: CASSANDRA_AUTO_BOOTSTRAP
111             value: {{ .Values.config.autoBootstrap | quote }}
112           - name: CASSANDRA_START_RPC
113             value: {{ default "true" .Values.config.start_rpc | quote }}
114           - name: CASSANDRA_ENDPOINT_SNITCH
115             value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
116           - name: CASSANDRA_AUTHENTICATOR
117             value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
118           {{- if  (include "common.serviceMesh" .) }}
119           - name: CASSANDRA_LISTEN_ADDRESS
120             value: "127.0.0.1"
121           - name: CASSANDRA_BROADCAST_ADDRESS
122             valueFrom:
123               fieldRef:
124                 fieldPath: status.podIP
125           {{- end }}
126           - name: POD_IP
127             valueFrom:
128               fieldRef:
129                 fieldPath: status.podIP
130         lifecycle:
131           preStop:
132             exec:
133         {{- if not .Values.persistence.enabled }}
134               command: ["/bin/sh", "-c", "exec nodetool decommission"]
135         {{- else }}
136               command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
137         {{- end }}
138         resources:
139 {{ toYaml .Values.resources | indent 10 }}
140       {{- if .Values.nodeSelector }}
141       nodeSelector:
142 {{ toYaml .Values.nodeSelector | indent 8 }}
143       {{- end -}}
144       {{- if .Values.affinity }}
145       affinity:
146 {{ toYaml .Values.affinity | indent 8 }}
147       {{- end }}
148       volumes:
149       - name: localtime
150         hostPath:
151           path: /etc/localtime
152       {{- range $key, $value := .Values.configOverrides }}
153       - name: cassandra-config-{{ $key | replace "." "-" }}
154         configMap:
155           name: {{ include "common.fullname" . }}-configOverrides
156       {{- end }}
157       - name: cassandra-entrypoint
158         configMap:
159           name: {{ include "common.fullname" . }}-entrypoint
160           defaultMode: 0755
161   {{- if not .Values.persistence.enabled }}
162       - name: {{ include "common.fullname" . }}-data
163         emptyDir: {}
164   {{- else }}
165   volumeClaimTemplates:
166     - metadata:
167         name: {{ include "common.fullname" . }}-data
168         labels:
169           name: {{ include "common.fullname" . }}
170           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
171           release: "{{ include "common.release" . }}"
172           heritage: "{{ .Release.Service }}"
173       spec:
174         accessModes:
175         {{- if .Values.backup.enabled }}
176         - ReadWriteMany
177         {{- else }}
178         - ReadWriteOnce
179         {{- end }}
180         storageClassName: {{ include "common.storageClass" . }}
181         resources:
182           requests:
183             storage: {{ .Values.persistence.size | quote }}
184   {{- end }}