Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / cassandra / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2022 Amdocs, AT&T, Bell Canada, Bitnami
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
17 {{- if not .Values.global.cassandra.useOperator }}
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   podManagementPolicy: {{ .Values.podManagementPolicy }}
26   updateStrategy:
27     type: {{ .Values.updateStrategy.type }}
28   template:
29     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
30     spec:
31       hostNetwork: {{ .Values.hostNetwork }}
32       {{- include "common.imagePullSecrets" . | nindent 6 }}
33       containers:
34       - name: {{ include "common.name" . }}
35         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
36         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
37         ports: {{ include "common.containerPorts" . | nindent 8  }}
38         volumeMounts:
39           - name: {{ include "common.fullname" . }}-data
40             mountPath: /var/lib/cassandra
41           - name: cassandra-entrypoint
42             mountPath: /docker-entrypoint.sh
43             subPath: docker-entrypoint.sh
44           {{- range $key, $value := .Values.configOverrides }}
45           - name: cassandra-config-{{ $key | replace "." "-" }}
46             mountPath: /etc/cassandra/{{ $key }}
47             subPath: {{ $key }}
48           {{- end }}
49         {{- if eq .Values.liveness.enabled true }}
50         livenessProbe:
51           exec:
52             command:
53             - /bin/bash
54             - -c
55             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
56           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
57           periodSeconds: {{ .Values.liveness.periodSeconds }}
58           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
59           successThreshold: {{ .Values.liveness.successThreshold }}
60           failureThreshold: {{ .Values.liveness.failureThreshold }}
61         {{ end }}
62         readinessProbe:
63           exec:
64             command:
65             - /bin/bash
66             - -c
67             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
68           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
69           periodSeconds: {{ .Values.readiness.periodSeconds }}
70           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
71           successThreshold: {{ .Values.readiness.successThreshold }}
72           failureThreshold: {{ .Values.readiness.failureThreshold }}
73         startupProbe:
74           exec:
75             command:
76             - /bin/bash
77             - -c
78             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
79           initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
80           periodSeconds: {{ .Values.startup.periodSeconds }}
81           timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
82           successThreshold: {{ .Values.startup.successThreshold }}
83           failureThreshold: {{ .Values.startup.failureThreshold }}
84         env:
85           {{- $seed_size := default 1 .Values.replicaCount | int -}}
86           {{- $global := . }}
87           - name: CASSANDRA_SEEDS
88           {{- if .Values.hostNetwork }}
89             value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
90           {{- else }}
91             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 }}"
92           {{- end }}
93           - name: MAX_HEAP_SIZE
94             value: {{ .Values.config.heap.max }}
95           - name: HEAP_NEWSIZE
96             value: {{ .Values.config.heap.min }}
97           - name: JVM_OPTS
98             value: {{ .Values.config.jvmOpts | quote }}
99           - name: CASSANDRA_CLUSTER_NAME
100             value: {{ .Values.config.clusterName | quote }}
101           - name: CASSANDRA_DC
102             value: {{ .Values.config.dataCenter | quote }}
103           - name: CASSANDRA_RACK
104             value: {{ .Values.config.rackName | quote }}
105           - name: CASSANDRA_AUTO_BOOTSTRAP
106             value: {{ .Values.config.autoBootstrap | quote }}
107           - name: CASSANDRA_START_RPC
108             value: {{ default "true" .Values.config.start_rpc | quote }}
109           - name: CASSANDRA_ENDPOINT_SNITCH
110             value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
111           - name: CASSANDRA_AUTHENTICATOR
112             value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
113           - name: POD_IP
114             valueFrom:
115               fieldRef:
116                 fieldPath: status.podIP
117         lifecycle:
118           preStop:
119             exec:
120         {{- if not .Values.persistence.enabled }}
121               command: ["/bin/sh", "-c", "exec nodetool decommission"]
122         {{- else }}
123               command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
124         {{- end }}
125         resources: {{ toYaml .Values.resources | nindent 10 }}
126       {{- if .Values.metrics.serviceMonitor.enabled }}
127       - name: {{ include "common.name" . }}-metrics
128         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.metrics.image }}
129         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.metrics.pullPolicy | quote}}
130         {{- if (.Values.metrics.enabled) }}
131         ports:
132         {{- range $index, $metricPort := .Values.metrics.ports }}
133         - name: {{ $metricPort.name }}
134           containerPort: {{ $metricPort.port }}
135           protocol: TCP
136         {{- end }}
137         livenessProbe:
138           httpGet:
139             path: {{ .Values.metrics.livenessProbe.httpGet.path }}
140             port: {{ .Values.metrics.livenessProbe.httpGet.port }}
141           initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
142           periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
143           timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
144           successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
145           failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
146         readinessProbe:
147           httpGet:
148             path: {{ .Values.metrics.readinessProbe.httpGet.path }}
149             port: {{ .Values.metrics.readinessProbe.httpGet.port }}
150           initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
151           periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
152           timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
153           successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
154           failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
155         {{- end }}
156         {{ include "common.containerSecurityContext" . | indent 10 | trim }}
157         {{- if .Values.metrics.resources }}
158         resources: {{- toYaml .Values.metrics.resources | nindent 10 }}
159         {{- end }}
160       {{- end }}
161       {{- if .Values.nodeSelector }}
162       nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
163       {{- end -}}
164       {{- if .Values.affinity }}
165       affinity: {{ toYaml .Values.affinity | nindent 8 }}
166       {{- end }}
167       serviceAccountName: {{ include "common.fullname" (dict "suffix" "nothing" "dot" . )}}
168       volumes:
169       {{- range $key, $value := .Values.configOverrides }}
170       - name: cassandra-config-{{ $key | replace "." "-" }}
171         configMap:
172           name: {{ include "common.fullname" . }}-configOverrides
173       {{- end }}
174       - name: cassandra-entrypoint
175         configMap:
176           name: {{ include "common.fullname" . }}-entrypoint
177           defaultMode: 0755
178   {{- if not .Values.persistence.enabled }}
179       - name: {{ include "common.fullname" . }}-data
180         emptyDir: {}
181   {{- else }}
182   volumeClaimTemplates:
183     - metadata:
184         name: {{ include "common.fullname" . }}-data
185         labels:
186           name: {{ include "common.fullname" . }}
187           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
188           release: "{{ include "common.release" . }}"
189           heritage: "{{ .Release.Service }}"
190       spec:
191         accessModes:
192         {{- if .Values.backup.enabled }}
193         - ReadWriteMany
194         {{- else }}
195         - ReadWriteOnce
196         {{- end }}
197         storageClassName: {{ include "common.storageClass" . }}
198         resources:
199           requests:
200             storage: {{ .Values.persistence.size | quote }}
201   {{- end }}
202 {{- end }}