blob: 4815d14594832b108855c83ac720515d0a10f502 [file] [log] [blame]
Jakub Latusek3659d9f2020-09-14 16:21:55 +02001{{/*
Suresh Charane1a70a12022-01-13 06:56:53 -05002# Copyright © 2022 Amdocs, AT&T, Bell Canada, Bitnami
prpatelafedf2c2018-09-07 15:28:38 +00003#
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.
Jakub Latusek3659d9f2020-09-14 16:21:55 +020015*/}}
prpatelafedf2c2018-09-07 15:28:38 +000016
Andreas Geisslercfd84342023-08-16 17:18:49 +020017{{- if not .Values.global.cassandra.useOperator }}
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010018apiVersion: apps/v1
prpatelafedf2c2018-09-07 15:28:38 +000019kind: StatefulSet
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010020metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
prpatelafedf2c2018-09-07 15:28:38 +000021spec:
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010022 selector: {{- include "common.selectors" . | nindent 4 }}
prpatelafedf2c2018-09-07 15:28:38 +000023 serviceName: {{ include "common.servicename" . }}
24 replicas: {{ .Values.replicaCount }}
25 podManagementPolicy: {{ .Values.podManagementPolicy }}
26 updateStrategy:
27 type: {{ .Values.updateStrategy.type }}
28 template:
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010029 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
prpatelafedf2c2018-09-07 15:28:38 +000030 spec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000031 hostNetwork: {{ .Values.hostNetwork }}
andreas-geisslerf84cccd2021-07-07 15:40:41 +020032 imagePullSecrets:
33 - name: "{{ include "common.namespace" . }}-docker-registry-key"
prpatelafedf2c2018-09-07 15:28:38 +000034 containers:
35 - name: {{ include "common.name" . }}
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010036 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
prpatelafedf2c2018-09-07 15:28:38 +000037 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010038 ports: {{ include "common.containerPorts" . | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +000039 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010040 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +000041 mountPath: /var/lib/cassandra
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000042 - name: localtime
43 mountPath: /etc/localtime
44 readOnly: true
mahendrr8b20f772019-05-03 06:50:10 +000045 - name: cassandra-entrypoint
46 mountPath: /docker-entrypoint.sh
47 subPath: docker-entrypoint.sh
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000048 {{- range $key, $value := .Values.configOverrides }}
49 - name: cassandra-config-{{ $key | replace "." "-" }}
50 mountPath: /etc/cassandra/{{ $key }}
51 subPath: {{ $key }}
52 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000053 {{- if eq .Values.liveness.enabled true }}
54 livenessProbe:
55 exec:
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010056 command:
prpatelafedf2c2018-09-07 15:28:38 +000057 - /bin/bash
58 - -c
59 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
60 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
61 periodSeconds: {{ .Values.liveness.periodSeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000062 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
63 successThreshold: {{ .Values.liveness.successThreshold }}
64 failureThreshold: {{ .Values.liveness.failureThreshold }}
Joey Sullivanbec0c982019-06-11 10:53:16 -040065 {{ end }}
prpatelafedf2c2018-09-07 15:28:38 +000066 readinessProbe:
67 exec:
68 command:
69 - /bin/bash
70 - -c
71 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
72 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000073 periodSeconds: {{ .Values.readiness.periodSeconds }}
74 timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
75 successThreshold: {{ .Values.readiness.successThreshold }}
76 failureThreshold: {{ .Values.readiness.failureThreshold }}
Sylvain Desbureauxe7616c32021-05-05 10:47:58 +020077 startupProbe:
78 exec:
79 command:
80 - /bin/bash
81 - -c
82 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
83 initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
84 periodSeconds: {{ .Values.startup.periodSeconds }}
85 timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
86 successThreshold: {{ .Values.startup.successThreshold }}
87 failureThreshold: {{ .Values.startup.failureThreshold }}
prpatelafedf2c2018-09-07 15:28:38 +000088 env:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000089 {{- $seed_size := default 1 .Values.replicaCount | int -}}
90 {{- $global := . }}
91 - name: CASSANDRA_SEEDS
92 {{- if .Values.hostNetwork }}
93 value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
94 {{- else }}
95 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 }}"
96 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000097 - name: MAX_HEAP_SIZE
98 value: {{ .Values.config.heap.max }}
99 - name: HEAP_NEWSIZE
100 value: {{ .Values.config.heap.min }}
101 - name: JVM_OPTS
102 value: {{ .Values.config.jvmOpts | quote }}
103 - name: CASSANDRA_CLUSTER_NAME
104 value: {{ .Values.config.clusterName | quote }}
105 - name: CASSANDRA_DC
106 value: {{ .Values.config.dataCenter | quote }}
107 - name: CASSANDRA_RACK
108 value: {{ .Values.config.rackName | quote }}
109 - name: CASSANDRA_AUTO_BOOTSTRAP
110 value: {{ .Values.config.autoBootstrap | quote }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000111 - name: CASSANDRA_START_RPC
112 value: {{ default "true" .Values.config.start_rpc | quote }}
113 - name: CASSANDRA_ENDPOINT_SNITCH
Mahendra Raghuwanshia9a4f312019-03-19 06:05:47 +0000114 value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
mahendrr8b20f772019-05-03 06:50:10 +0000115 - name: CASSANDRA_AUTHENTICATOR
116 value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000117 - name: POD_IP
118 valueFrom:
119 fieldRef:
120 fieldPath: status.podIP
prpatelafedf2c2018-09-07 15:28:38 +0000121 lifecycle:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000122 preStop:
prpatelafedf2c2018-09-07 15:28:38 +0000123 exec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000124 {{- if not .Values.persistence.enabled }}
125 command: ["/bin/sh", "-c", "exec nodetool decommission"]
126 {{- else }}
127 command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
128 {{- end }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200129 resources: {{ toYaml .Values.resources | nindent 10 }}
Suresh Charane1a70a12022-01-13 06:56:53 -0500130 {{- if .Values.metrics.serviceMonitor.enabled }}
131 - name: {{ include "common.name" . }}-metrics
132 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.metrics.image }}
133 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.metrics.pullPolicy | quote}}
134 {{- if (.Values.metrics.enabled) }}
135 ports:
136 {{- range $index, $metricPort := .Values.metrics.ports }}
137 - name: {{ $metricPort.name }}
138 containerPort: {{ $metricPort.port }}
139 protocol: TCP
140 {{- end }}
141 livenessProbe:
142 httpGet:
143 path: {{ .Values.metrics.livenessProbe.httpGet.path }}
144 port: {{ .Values.metrics.livenessProbe.httpGet.port }}
145 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
146 periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
147 timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
148 successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
149 failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
150 readinessProbe:
151 httpGet:
152 path: {{ .Values.metrics.readinessProbe.httpGet.path }}
153 port: {{ .Values.metrics.readinessProbe.httpGet.port }}
154 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
155 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
156 timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
157 successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
158 failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
159 {{- end }}
160 {{ include "common.containerSecurityContext" . | indent 10 | trim }}
161 {{- if .Values.metrics.resources }}
162 resources: {{- toYaml .Values.metrics.resources | nindent 10 }}
163 {{- end }}
164 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000165 {{- if .Values.nodeSelector }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200166 nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000167 {{- end -}}
168 {{- if .Values.affinity }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200169 affinity: {{ toYaml .Values.affinity | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000170 {{- end }}
farida azmy661c81a2021-03-09 11:38:20 +0200171 serviceAccountName: {{ include "common.fullname" (dict "suffix" "nothing" "dot" . )}}
prpatelafedf2c2018-09-07 15:28:38 +0000172 volumes:
173 - name: localtime
174 hostPath:
175 path: /etc/localtime
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000176 {{- range $key, $value := .Values.configOverrides }}
177 - name: cassandra-config-{{ $key | replace "." "-" }}
prpatelafedf2c2018-09-07 15:28:38 +0000178 configMap:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000179 name: {{ include "common.fullname" . }}-configOverrides
180 {{- end }}
mahendrr8b20f772019-05-03 06:50:10 +0000181 - name: cassandra-entrypoint
182 configMap:
183 name: {{ include "common.fullname" . }}-entrypoint
184 defaultMode: 0755
prpatelafedf2c2018-09-07 15:28:38 +0000185 {{- if not .Values.persistence.enabled }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100186 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000187 emptyDir: {}
188 {{- else }}
189 volumeClaimTemplates:
190 - metadata:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100191 name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000192 labels:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100193 name: {{ include "common.fullname" . }}
194 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100195 release: "{{ include "common.release" . }}"
prpatelafedf2c2018-09-07 15:28:38 +0000196 heritage: "{{ .Release.Service }}"
prpatelafedf2c2018-09-07 15:28:38 +0000197 spec:
198 accessModes:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100199 {{- if .Values.backup.enabled }}
200 - ReadWriteMany
201 {{- else }}
202 - ReadWriteOnce
203 {{- end }}
204 storageClassName: {{ include "common.storageClass" . }}
prpatelafedf2c2018-09-07 15:28:38 +0000205 resources:
206 requests:
207 storage: {{ .Values.persistence.size | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000208 {{- end }}
dasarathi52802465e8f782023-05-03 09:51:20 +0000209{{- end }}