blob: 2e73309bb762f8e61dd6d7d795bcf3591cdd097e [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
dasarathi52802465e8f782023-05-03 09:51:20 +000017{{- if not .Values.k8ssandraOperator.enabled }}
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 }}
Suresh Charane1a70a12022-01-13 06:56:53 -050030 {{- if or .Values.podAnnotations (and .Values.metrics.serviceMonitor.enabled .Values.metrics.podAnnotations) }}
31 annotations:
32 {{- if .Values.podAnnotations }}
33 {{- include "common.tplValue" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
34 {{- end }}
35 {{- if and .Values.metrics.serviceMonitor.enabled .Values.metrics.podAnnotations }}
36 {{- include "common.tplValue" (dict "value" .Values.metrics.podAnnotations "context" $) | nindent 8 }}
37 {{- end }}
38 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000039 spec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000040 hostNetwork: {{ .Values.hostNetwork }}
andreas-geisslerf84cccd2021-07-07 15:40:41 +020041 imagePullSecrets:
42 - name: "{{ include "common.namespace" . }}-docker-registry-key"
prpatelafedf2c2018-09-07 15:28:38 +000043 containers:
44 - name: {{ include "common.name" . }}
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010045 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
prpatelafedf2c2018-09-07 15:28:38 +000046 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010047 ports: {{ include "common.containerPorts" . | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +000048 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010049 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +000050 mountPath: /var/lib/cassandra
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000051 - name: localtime
52 mountPath: /etc/localtime
53 readOnly: true
mahendrr8b20f772019-05-03 06:50:10 +000054 - name: cassandra-entrypoint
55 mountPath: /docker-entrypoint.sh
56 subPath: docker-entrypoint.sh
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000057 {{- range $key, $value := .Values.configOverrides }}
58 - name: cassandra-config-{{ $key | replace "." "-" }}
59 mountPath: /etc/cassandra/{{ $key }}
60 subPath: {{ $key }}
61 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000062 {{- if eq .Values.liveness.enabled true }}
63 livenessProbe:
64 exec:
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010065 command:
prpatelafedf2c2018-09-07 15:28:38 +000066 - /bin/bash
67 - -c
68 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
69 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
70 periodSeconds: {{ .Values.liveness.periodSeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000071 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
72 successThreshold: {{ .Values.liveness.successThreshold }}
73 failureThreshold: {{ .Values.liveness.failureThreshold }}
Joey Sullivanbec0c982019-06-11 10:53:16 -040074 {{ end }}
prpatelafedf2c2018-09-07 15:28:38 +000075 readinessProbe:
76 exec:
77 command:
78 - /bin/bash
79 - -c
80 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
81 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000082 periodSeconds: {{ .Values.readiness.periodSeconds }}
83 timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
84 successThreshold: {{ .Values.readiness.successThreshold }}
85 failureThreshold: {{ .Values.readiness.failureThreshold }}
Sylvain Desbureauxe7616c32021-05-05 10:47:58 +020086 startupProbe:
87 exec:
88 command:
89 - /bin/bash
90 - -c
91 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
92 initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
93 periodSeconds: {{ .Values.startup.periodSeconds }}
94 timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
95 successThreshold: {{ .Values.startup.successThreshold }}
96 failureThreshold: {{ .Values.startup.failureThreshold }}
prpatelafedf2c2018-09-07 15:28:38 +000097 env:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000098 {{- $seed_size := default 1 .Values.replicaCount | int -}}
99 {{- $global := . }}
100 - name: CASSANDRA_SEEDS
101 {{- if .Values.hostNetwork }}
102 value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
103 {{- else }}
104 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 }}"
105 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000106 - name: MAX_HEAP_SIZE
107 value: {{ .Values.config.heap.max }}
108 - name: HEAP_NEWSIZE
109 value: {{ .Values.config.heap.min }}
110 - name: JVM_OPTS
111 value: {{ .Values.config.jvmOpts | quote }}
112 - name: CASSANDRA_CLUSTER_NAME
113 value: {{ .Values.config.clusterName | quote }}
114 - name: CASSANDRA_DC
115 value: {{ .Values.config.dataCenter | quote }}
116 - name: CASSANDRA_RACK
117 value: {{ .Values.config.rackName | quote }}
118 - name: CASSANDRA_AUTO_BOOTSTRAP
119 value: {{ .Values.config.autoBootstrap | quote }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000120 - name: CASSANDRA_START_RPC
121 value: {{ default "true" .Values.config.start_rpc | quote }}
122 - name: CASSANDRA_ENDPOINT_SNITCH
Mahendra Raghuwanshia9a4f312019-03-19 06:05:47 +0000123 value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
mahendrr8b20f772019-05-03 06:50:10 +0000124 - name: CASSANDRA_AUTHENTICATOR
125 value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000126 - name: POD_IP
127 valueFrom:
128 fieldRef:
129 fieldPath: status.podIP
prpatelafedf2c2018-09-07 15:28:38 +0000130 lifecycle:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000131 preStop:
prpatelafedf2c2018-09-07 15:28:38 +0000132 exec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000133 {{- 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 }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200138 resources: {{ toYaml .Values.resources | nindent 10 }}
Suresh Charane1a70a12022-01-13 06:56:53 -0500139 {{- if .Values.metrics.serviceMonitor.enabled }}
140 - name: {{ include "common.name" . }}-metrics
141 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.metrics.image }}
142 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.metrics.pullPolicy | quote}}
143 {{- if (.Values.metrics.enabled) }}
144 ports:
145 {{- range $index, $metricPort := .Values.metrics.ports }}
146 - name: {{ $metricPort.name }}
147 containerPort: {{ $metricPort.port }}
148 protocol: TCP
149 {{- end }}
150 livenessProbe:
151 httpGet:
152 path: {{ .Values.metrics.livenessProbe.httpGet.path }}
153 port: {{ .Values.metrics.livenessProbe.httpGet.port }}
154 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
155 periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
156 timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
157 successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
158 failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
159 readinessProbe:
160 httpGet:
161 path: {{ .Values.metrics.readinessProbe.httpGet.path }}
162 port: {{ .Values.metrics.readinessProbe.httpGet.port }}
163 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
164 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
165 timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
166 successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
167 failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
168 {{- end }}
169 {{ include "common.containerSecurityContext" . | indent 10 | trim }}
170 {{- if .Values.metrics.resources }}
171 resources: {{- toYaml .Values.metrics.resources | nindent 10 }}
172 {{- end }}
173 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000174 {{- if .Values.nodeSelector }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200175 nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000176 {{- end -}}
177 {{- if .Values.affinity }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200178 affinity: {{ toYaml .Values.affinity | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000179 {{- end }}
farida azmy661c81a2021-03-09 11:38:20 +0200180 serviceAccountName: {{ include "common.fullname" (dict "suffix" "nothing" "dot" . )}}
prpatelafedf2c2018-09-07 15:28:38 +0000181 volumes:
182 - name: localtime
183 hostPath:
184 path: /etc/localtime
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000185 {{- range $key, $value := .Values.configOverrides }}
186 - name: cassandra-config-{{ $key | replace "." "-" }}
prpatelafedf2c2018-09-07 15:28:38 +0000187 configMap:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000188 name: {{ include "common.fullname" . }}-configOverrides
189 {{- end }}
mahendrr8b20f772019-05-03 06:50:10 +0000190 - name: cassandra-entrypoint
191 configMap:
192 name: {{ include "common.fullname" . }}-entrypoint
193 defaultMode: 0755
prpatelafedf2c2018-09-07 15:28:38 +0000194 {{- if not .Values.persistence.enabled }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100195 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000196 emptyDir: {}
197 {{- else }}
198 volumeClaimTemplates:
199 - metadata:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100200 name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000201 labels:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100202 name: {{ include "common.fullname" . }}
203 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100204 release: "{{ include "common.release" . }}"
prpatelafedf2c2018-09-07 15:28:38 +0000205 heritage: "{{ .Release.Service }}"
prpatelafedf2c2018-09-07 15:28:38 +0000206 spec:
207 accessModes:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100208 {{- if .Values.backup.enabled }}
209 - ReadWriteMany
210 {{- else }}
211 - ReadWriteOnce
212 {{- end }}
213 storageClassName: {{ include "common.storageClass" . }}
prpatelafedf2c2018-09-07 15:28:38 +0000214 resources:
215 requests:
216 storage: {{ .Values.persistence.size | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000217 {{- end }}
dasarathi52802465e8f782023-05-03 09:51:20 +0000218{{- end }}