blob: 840e95b490be440c2a2420ca891f0b66e30a8a72 [file] [log] [blame]
Jakub Latusek3659d9f2020-09-14 16:21:55 +02001{{/*
prpatelafedf2c2018-09-07 15:28:38 +00002# Copyright © 2018 Amdocs, AT&T, Bell Canada
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.
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 }}
prpatelafedf2c2018-09-07 15:28:38 +000029 spec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000030 hostNetwork: {{ .Values.hostNetwork }}
andreas-geisslerf84cccd2021-07-07 15:40:41 +020031 imagePullSecrets:
32 - name: "{{ include "common.namespace" . }}-docker-registry-key"
prpatelafedf2c2018-09-07 15:28:38 +000033 containers:
34 - name: {{ include "common.name" . }}
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010035 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
prpatelafedf2c2018-09-07 15:28:38 +000036 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010037 ports: {{ include "common.containerPorts" . | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +000038 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010039 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +000040 mountPath: /var/lib/cassandra
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000041 - name: localtime
42 mountPath: /etc/localtime
43 readOnly: true
mahendrr8b20f772019-05-03 06:50:10 +000044 - name: cassandra-entrypoint
45 mountPath: /docker-entrypoint.sh
46 subPath: docker-entrypoint.sh
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000047 {{- range $key, $value := .Values.configOverrides }}
48 - name: cassandra-config-{{ $key | replace "." "-" }}
49 mountPath: /etc/cassandra/{{ $key }}
50 subPath: {{ $key }}
51 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000052 {{- if eq .Values.liveness.enabled true }}
53 livenessProbe:
54 exec:
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010055 command:
prpatelafedf2c2018-09-07 15:28:38 +000056 - /bin/bash
57 - -c
58 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
59 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
60 periodSeconds: {{ .Values.liveness.periodSeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000061 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
62 successThreshold: {{ .Values.liveness.successThreshold }}
63 failureThreshold: {{ .Values.liveness.failureThreshold }}
Joey Sullivanbec0c982019-06-11 10:53:16 -040064 {{ end }}
prpatelafedf2c2018-09-07 15:28:38 +000065 readinessProbe:
66 exec:
67 command:
68 - /bin/bash
69 - -c
70 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
71 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000072 periodSeconds: {{ .Values.readiness.periodSeconds }}
73 timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
74 successThreshold: {{ .Values.readiness.successThreshold }}
75 failureThreshold: {{ .Values.readiness.failureThreshold }}
Sylvain Desbureauxe7616c32021-05-05 10:47:58 +020076 startupProbe:
77 exec:
78 command:
79 - /bin/bash
80 - -c
81 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
82 initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
83 periodSeconds: {{ .Values.startup.periodSeconds }}
84 timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
85 successThreshold: {{ .Values.startup.successThreshold }}
86 failureThreshold: {{ .Values.startup.failureThreshold }}
prpatelafedf2c2018-09-07 15:28:38 +000087 env:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000088 {{- $seed_size := default 1 .Values.replicaCount | int -}}
89 {{- $global := . }}
90 - name: CASSANDRA_SEEDS
91 {{- if .Values.hostNetwork }}
92 value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
93 {{- else }}
94 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 }}"
95 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000096 - name: MAX_HEAP_SIZE
97 value: {{ .Values.config.heap.max }}
98 - name: HEAP_NEWSIZE
99 value: {{ .Values.config.heap.min }}
100 - name: JVM_OPTS
101 value: {{ .Values.config.jvmOpts | quote }}
102 - name: CASSANDRA_CLUSTER_NAME
103 value: {{ .Values.config.clusterName | quote }}
104 - name: CASSANDRA_DC
105 value: {{ .Values.config.dataCenter | quote }}
106 - name: CASSANDRA_RACK
107 value: {{ .Values.config.rackName | quote }}
108 - name: CASSANDRA_AUTO_BOOTSTRAP
109 value: {{ .Values.config.autoBootstrap | quote }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000110 - name: CASSANDRA_START_RPC
111 value: {{ default "true" .Values.config.start_rpc | quote }}
112 - name: CASSANDRA_ENDPOINT_SNITCH
Mahendra Raghuwanshia9a4f312019-03-19 06:05:47 +0000113 value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
mahendrr8b20f772019-05-03 06:50:10 +0000114 - name: CASSANDRA_AUTHENTICATOR
115 value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000116 - name: POD_IP
117 valueFrom:
118 fieldRef:
119 fieldPath: status.podIP
prpatelafedf2c2018-09-07 15:28:38 +0000120 lifecycle:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000121 preStop:
prpatelafedf2c2018-09-07 15:28:38 +0000122 exec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000123 {{- if not .Values.persistence.enabled }}
124 command: ["/bin/sh", "-c", "exec nodetool decommission"]
125 {{- else }}
126 command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
127 {{- end }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200128 resources: {{ toYaml .Values.resources | nindent 10 }}
prpatelafedf2c2018-09-07 15:28:38 +0000129 {{- if .Values.nodeSelector }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200130 nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000131 {{- end -}}
132 {{- if .Values.affinity }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200133 affinity: {{ toYaml .Values.affinity | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000134 {{- end }}
farida azmy661c81a2021-03-09 11:38:20 +0200135 serviceAccountName: {{ include "common.fullname" (dict "suffix" "nothing" "dot" . )}}
prpatelafedf2c2018-09-07 15:28:38 +0000136 volumes:
137 - name: localtime
138 hostPath:
139 path: /etc/localtime
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000140 {{- range $key, $value := .Values.configOverrides }}
141 - name: cassandra-config-{{ $key | replace "." "-" }}
prpatelafedf2c2018-09-07 15:28:38 +0000142 configMap:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000143 name: {{ include "common.fullname" . }}-configOverrides
144 {{- end }}
mahendrr8b20f772019-05-03 06:50:10 +0000145 - name: cassandra-entrypoint
146 configMap:
147 name: {{ include "common.fullname" . }}-entrypoint
148 defaultMode: 0755
prpatelafedf2c2018-09-07 15:28:38 +0000149 {{- if not .Values.persistence.enabled }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100150 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000151 emptyDir: {}
152 {{- else }}
153 volumeClaimTemplates:
154 - metadata:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100155 name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000156 labels:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100157 name: {{ include "common.fullname" . }}
158 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100159 release: "{{ include "common.release" . }}"
prpatelafedf2c2018-09-07 15:28:38 +0000160 heritage: "{{ .Release.Service }}"
prpatelafedf2c2018-09-07 15:28:38 +0000161 spec:
162 accessModes:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100163 {{- if .Values.backup.enabled }}
164 - ReadWriteMany
165 {{- else }}
166 - ReadWriteOnce
167 {{- end }}
168 storageClassName: {{ include "common.storageClass" . }}
prpatelafedf2c2018-09-07 15:28:38 +0000169 resources:
170 requests:
171 storage: {{ .Values.persistence.size | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000172 {{- end }}