blob: 43367ee5421178799267285132c74a9598cff522 [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
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010017apiVersion: apps/v1
prpatelafedf2c2018-09-07 15:28:38 +000018kind: StatefulSet
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010019metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
prpatelafedf2c2018-09-07 15:28:38 +000020spec:
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010021 selector: {{- include "common.selectors" . | nindent 4 }}
prpatelafedf2c2018-09-07 15:28:38 +000022 serviceName: {{ include "common.servicename" . }}
23 replicas: {{ .Values.replicaCount }}
24 podManagementPolicy: {{ .Values.podManagementPolicy }}
25 updateStrategy:
26 type: {{ .Values.updateStrategy.type }}
27 template:
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010028 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
Suresh Charane1a70a12022-01-13 06:56:53 -050029 {{- if or .Values.podAnnotations (and .Values.metrics.serviceMonitor.enabled .Values.metrics.podAnnotations) }}
30 annotations:
31 {{- if .Values.podAnnotations }}
32 {{- include "common.tplValue" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
33 {{- end }}
34 {{- if and .Values.metrics.serviceMonitor.enabled .Values.metrics.podAnnotations }}
35 {{- include "common.tplValue" (dict "value" .Values.metrics.podAnnotations "context" $) | nindent 8 }}
36 {{- end }}
37 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000038 spec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000039 hostNetwork: {{ .Values.hostNetwork }}
andreas-geisslerf84cccd2021-07-07 15:40:41 +020040 imagePullSecrets:
41 - name: "{{ include "common.namespace" . }}-docker-registry-key"
prpatelafedf2c2018-09-07 15:28:38 +000042 containers:
43 - name: {{ include "common.name" . }}
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010044 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
prpatelafedf2c2018-09-07 15:28:38 +000045 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010046 ports: {{ include "common.containerPorts" . | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +000047 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010048 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +000049 mountPath: /var/lib/cassandra
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000050 - name: localtime
51 mountPath: /etc/localtime
52 readOnly: true
mahendrr8b20f772019-05-03 06:50:10 +000053 - name: cassandra-entrypoint
54 mountPath: /docker-entrypoint.sh
55 subPath: docker-entrypoint.sh
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000056 {{- range $key, $value := .Values.configOverrides }}
57 - name: cassandra-config-{{ $key | replace "." "-" }}
58 mountPath: /etc/cassandra/{{ $key }}
59 subPath: {{ $key }}
60 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000061 {{- if eq .Values.liveness.enabled true }}
62 livenessProbe:
63 exec:
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010064 command:
prpatelafedf2c2018-09-07 15:28:38 +000065 - /bin/bash
66 - -c
67 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
68 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
69 periodSeconds: {{ .Values.liveness.periodSeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000070 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
71 successThreshold: {{ .Values.liveness.successThreshold }}
72 failureThreshold: {{ .Values.liveness.failureThreshold }}
Joey Sullivanbec0c982019-06-11 10:53:16 -040073 {{ end }}
prpatelafedf2c2018-09-07 15:28:38 +000074 readinessProbe:
75 exec:
76 command:
77 - /bin/bash
78 - -c
79 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
80 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000081 periodSeconds: {{ .Values.readiness.periodSeconds }}
82 timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
83 successThreshold: {{ .Values.readiness.successThreshold }}
84 failureThreshold: {{ .Values.readiness.failureThreshold }}
Sylvain Desbureauxe7616c32021-05-05 10:47:58 +020085 startupProbe:
86 exec:
87 command:
88 - /bin/bash
89 - -c
90 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
91 initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
92 periodSeconds: {{ .Values.startup.periodSeconds }}
93 timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
94 successThreshold: {{ .Values.startup.successThreshold }}
95 failureThreshold: {{ .Values.startup.failureThreshold }}
prpatelafedf2c2018-09-07 15:28:38 +000096 env:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000097 {{- $seed_size := default 1 .Values.replicaCount | int -}}
98 {{- $global := . }}
99 - name: CASSANDRA_SEEDS
100 {{- if .Values.hostNetwork }}
101 value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
102 {{- else }}
103 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 }}"
104 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000105 - name: MAX_HEAP_SIZE
106 value: {{ .Values.config.heap.max }}
107 - name: HEAP_NEWSIZE
108 value: {{ .Values.config.heap.min }}
109 - name: JVM_OPTS
110 value: {{ .Values.config.jvmOpts | quote }}
111 - name: CASSANDRA_CLUSTER_NAME
112 value: {{ .Values.config.clusterName | quote }}
113 - name: CASSANDRA_DC
114 value: {{ .Values.config.dataCenter | quote }}
115 - name: CASSANDRA_RACK
116 value: {{ .Values.config.rackName | quote }}
117 - name: CASSANDRA_AUTO_BOOTSTRAP
118 value: {{ .Values.config.autoBootstrap | quote }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000119 - name: CASSANDRA_START_RPC
120 value: {{ default "true" .Values.config.start_rpc | quote }}
121 - name: CASSANDRA_ENDPOINT_SNITCH
Mahendra Raghuwanshia9a4f312019-03-19 06:05:47 +0000122 value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
mahendrr8b20f772019-05-03 06:50:10 +0000123 - name: CASSANDRA_AUTHENTICATOR
124 value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000125 - name: POD_IP
126 valueFrom:
127 fieldRef:
128 fieldPath: status.podIP
prpatelafedf2c2018-09-07 15:28:38 +0000129 lifecycle:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000130 preStop:
prpatelafedf2c2018-09-07 15:28:38 +0000131 exec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000132 {{- if not .Values.persistence.enabled }}
133 command: ["/bin/sh", "-c", "exec nodetool decommission"]
134 {{- else }}
135 command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
136 {{- end }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200137 resources: {{ toYaml .Values.resources | nindent 10 }}
Suresh Charane1a70a12022-01-13 06:56:53 -0500138 {{- if .Values.metrics.serviceMonitor.enabled }}
139 - name: {{ include "common.name" . }}-metrics
140 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.metrics.image }}
141 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.metrics.pullPolicy | quote}}
142 {{- if (.Values.metrics.enabled) }}
143 ports:
144 {{- range $index, $metricPort := .Values.metrics.ports }}
145 - name: {{ $metricPort.name }}
146 containerPort: {{ $metricPort.port }}
147 protocol: TCP
148 {{- end }}
149 livenessProbe:
150 httpGet:
151 path: {{ .Values.metrics.livenessProbe.httpGet.path }}
152 port: {{ .Values.metrics.livenessProbe.httpGet.port }}
153 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
154 periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
155 timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
156 successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
157 failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
158 readinessProbe:
159 httpGet:
160 path: {{ .Values.metrics.readinessProbe.httpGet.path }}
161 port: {{ .Values.metrics.readinessProbe.httpGet.port }}
162 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
163 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
164 timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
165 successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
166 failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
167 {{- end }}
168 {{ include "common.containerSecurityContext" . | indent 10 | trim }}
169 {{- if .Values.metrics.resources }}
170 resources: {{- toYaml .Values.metrics.resources | nindent 10 }}
171 {{- end }}
172 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000173 {{- if .Values.nodeSelector }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200174 nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000175 {{- end -}}
176 {{- if .Values.affinity }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200177 affinity: {{ toYaml .Values.affinity | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000178 {{- end }}
farida azmy661c81a2021-03-09 11:38:20 +0200179 serviceAccountName: {{ include "common.fullname" (dict "suffix" "nothing" "dot" . )}}
prpatelafedf2c2018-09-07 15:28:38 +0000180 volumes:
181 - name: localtime
182 hostPath:
183 path: /etc/localtime
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000184 {{- range $key, $value := .Values.configOverrides }}
185 - name: cassandra-config-{{ $key | replace "." "-" }}
prpatelafedf2c2018-09-07 15:28:38 +0000186 configMap:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000187 name: {{ include "common.fullname" . }}-configOverrides
188 {{- end }}
mahendrr8b20f772019-05-03 06:50:10 +0000189 - name: cassandra-entrypoint
190 configMap:
191 name: {{ include "common.fullname" . }}-entrypoint
192 defaultMode: 0755
prpatelafedf2c2018-09-07 15:28:38 +0000193 {{- if not .Values.persistence.enabled }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100194 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000195 emptyDir: {}
196 {{- else }}
197 volumeClaimTemplates:
198 - metadata:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100199 name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000200 labels:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100201 name: {{ include "common.fullname" . }}
202 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100203 release: "{{ include "common.release" . }}"
prpatelafedf2c2018-09-07 15:28:38 +0000204 heritage: "{{ .Release.Service }}"
prpatelafedf2c2018-09-07 15:28:38 +0000205 spec:
206 accessModes:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100207 {{- if .Values.backup.enabled }}
208 - ReadWriteMany
209 {{- else }}
210 - ReadWriteOnce
211 {{- end }}
212 storageClassName: {{ include "common.storageClass" . }}
prpatelafedf2c2018-09-07 15:28:38 +0000213 resources:
214 requests:
215 storage: {{ .Values.persistence.size | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000216 {{- end }}