blob: 3553cd406957a8a0603471bd5b0e5b3cd9162ca4 [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 }}
prpatelafedf2c2018-09-07 15:28:38 +000031 containers:
32 - name: {{ include "common.name" . }}
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010033 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
prpatelafedf2c2018-09-07 15:28:38 +000034 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010035 ports: {{ include "common.containerPorts" . | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +000036 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010037 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +000038 mountPath: /var/lib/cassandra
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000039 - name: localtime
40 mountPath: /etc/localtime
41 readOnly: true
mahendrr8b20f772019-05-03 06:50:10 +000042 - name: cassandra-entrypoint
43 mountPath: /docker-entrypoint.sh
44 subPath: docker-entrypoint.sh
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000045 {{- range $key, $value := .Values.configOverrides }}
46 - name: cassandra-config-{{ $key | replace "." "-" }}
47 mountPath: /etc/cassandra/{{ $key }}
48 subPath: {{ $key }}
49 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000050 {{- if eq .Values.liveness.enabled true }}
51 livenessProbe:
52 exec:
Sylvain Desbureaux7743d8b2020-11-19 16:45:23 +010053 command:
prpatelafedf2c2018-09-07 15:28:38 +000054 - /bin/bash
55 - -c
56 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
57 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
58 periodSeconds: {{ .Values.liveness.periodSeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000059 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
60 successThreshold: {{ .Values.liveness.successThreshold }}
61 failureThreshold: {{ .Values.liveness.failureThreshold }}
Joey Sullivanbec0c982019-06-11 10:53:16 -040062 {{ end }}
prpatelafedf2c2018-09-07 15:28:38 +000063 readinessProbe:
64 exec:
65 command:
66 - /bin/bash
67 - -c
68 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
69 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000070 periodSeconds: {{ .Values.readiness.periodSeconds }}
71 timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
72 successThreshold: {{ .Values.readiness.successThreshold }}
73 failureThreshold: {{ .Values.readiness.failureThreshold }}
Sylvain Desbureauxe7616c32021-05-05 10:47:58 +020074 startupProbe:
75 exec:
76 command:
77 - /bin/bash
78 - -c
79 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
80 initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
81 periodSeconds: {{ .Values.startup.periodSeconds }}
82 timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
83 successThreshold: {{ .Values.startup.successThreshold }}
84 failureThreshold: {{ .Values.startup.failureThreshold }}
prpatelafedf2c2018-09-07 15:28:38 +000085 env:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000086 {{- $seed_size := default 1 .Values.replicaCount | int -}}
87 {{- $global := . }}
88 - name: CASSANDRA_SEEDS
89 {{- if .Values.hostNetwork }}
90 value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
91 {{- else }}
92 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 }}"
93 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000094 - name: MAX_HEAP_SIZE
95 value: {{ .Values.config.heap.max }}
96 - name: HEAP_NEWSIZE
97 value: {{ .Values.config.heap.min }}
98 - name: JVM_OPTS
99 value: {{ .Values.config.jvmOpts | quote }}
100 - name: CASSANDRA_CLUSTER_NAME
101 value: {{ .Values.config.clusterName | quote }}
102 - name: CASSANDRA_DC
103 value: {{ .Values.config.dataCenter | quote }}
104 - name: CASSANDRA_RACK
105 value: {{ .Values.config.rackName | quote }}
106 - name: CASSANDRA_AUTO_BOOTSTRAP
107 value: {{ .Values.config.autoBootstrap | quote }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000108 - name: CASSANDRA_START_RPC
109 value: {{ default "true" .Values.config.start_rpc | quote }}
110 - name: CASSANDRA_ENDPOINT_SNITCH
Mahendra Raghuwanshia9a4f312019-03-19 06:05:47 +0000111 value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
mahendrr8b20f772019-05-03 06:50:10 +0000112 - name: CASSANDRA_AUTHENTICATOR
113 value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
Sylvain Desbureaux09c55c82021-02-01 15:05:48 +0100114 {{- if include "common.onServiceMesh" . }}
115 - name: CASSANDRA_LISTEN_ADDRESS
116 value: "127.0.0.1"
117 - name: CASSANDRA_BROADCAST_ADDRESS
118 valueFrom:
119 fieldRef:
120 fieldPath: status.podIP
121 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000122 - name: POD_IP
123 valueFrom:
124 fieldRef:
125 fieldPath: status.podIP
prpatelafedf2c2018-09-07 15:28:38 +0000126 lifecycle:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000127 preStop:
prpatelafedf2c2018-09-07 15:28:38 +0000128 exec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000129 {{- if not .Values.persistence.enabled }}
130 command: ["/bin/sh", "-c", "exec nodetool decommission"]
131 {{- else }}
132 command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
133 {{- end }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200134 resources: {{ toYaml .Values.resources | nindent 10 }}
prpatelafedf2c2018-09-07 15:28:38 +0000135 {{- if .Values.nodeSelector }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200136 nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000137 {{- end -}}
138 {{- if .Values.affinity }}
Sylvain Desbureaux77c848a2020-09-23 14:21:30 +0200139 affinity: {{ toYaml .Values.affinity | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +0000140 {{- end }}
141 volumes:
142 - name: localtime
143 hostPath:
144 path: /etc/localtime
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000145 {{- range $key, $value := .Values.configOverrides }}
146 - name: cassandra-config-{{ $key | replace "." "-" }}
prpatelafedf2c2018-09-07 15:28:38 +0000147 configMap:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000148 name: {{ include "common.fullname" . }}-configOverrides
149 {{- end }}
mahendrr8b20f772019-05-03 06:50:10 +0000150 - name: cassandra-entrypoint
151 configMap:
152 name: {{ include "common.fullname" . }}-entrypoint
153 defaultMode: 0755
prpatelafedf2c2018-09-07 15:28:38 +0000154 {{- if not .Values.persistence.enabled }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100155 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000156 emptyDir: {}
157 {{- else }}
158 volumeClaimTemplates:
159 - metadata:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100160 name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000161 labels:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100162 name: {{ include "common.fullname" . }}
163 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100164 release: "{{ include "common.release" . }}"
prpatelafedf2c2018-09-07 15:28:38 +0000165 heritage: "{{ .Release.Service }}"
prpatelafedf2c2018-09-07 15:28:38 +0000166 spec:
167 accessModes:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100168 {{- if .Values.backup.enabled }}
169 - ReadWriteMany
170 {{- else }}
171 - ReadWriteOnce
172 {{- end }}
173 storageClassName: {{ include "common.storageClass" . }}
prpatelafedf2c2018-09-07 15:28:38 +0000174 resources:
175 requests:
176 storage: {{ .Values.persistence.size | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000177 {{- end }}