blob: 96139ce98802039e6cb162b30fca46eab1304173 [file] [log] [blame]
prpatelafedf2c2018-09-07 15:28:38 +00001# Copyright © 2018 Amdocs, AT&T, Bell Canada
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010015apiVersion: apps/v1
prpatelafedf2c2018-09-07 15:28:38 +000016kind: StatefulSet
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010017metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
prpatelafedf2c2018-09-07 15:28:38 +000018spec:
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010019 selector: {{- include "common.selectors" . | nindent 4 }}
prpatelafedf2c2018-09-07 15:28:38 +000020 serviceName: {{ include "common.servicename" . }}
21 replicas: {{ .Values.replicaCount }}
22 podManagementPolicy: {{ .Values.podManagementPolicy }}
23 updateStrategy:
24 type: {{ .Values.updateStrategy.type }}
25 template:
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010026 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
prpatelafedf2c2018-09-07 15:28:38 +000027 spec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000028 hostNetwork: {{ .Values.hostNetwork }}
prpatelafedf2c2018-09-07 15:28:38 +000029 containers:
30 - name: {{ include "common.name" . }}
afennerfc5f8042020-04-17 12:09:01 +010031 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
prpatelafedf2c2018-09-07 15:28:38 +000032 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Sylvain Desbureaux60c74802019-12-12 14:35:01 +010033 ports: {{ include "common.containerPorts" . | nindent 8 }}
prpatelafedf2c2018-09-07 15:28:38 +000034 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010035 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +000036 mountPath: /var/lib/cassandra
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000037 - name: localtime
38 mountPath: /etc/localtime
39 readOnly: true
mahendrr8b20f772019-05-03 06:50:10 +000040 - name: cassandra-entrypoint
41 mountPath: /docker-entrypoint.sh
42 subPath: docker-entrypoint.sh
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000043 {{- range $key, $value := .Values.configOverrides }}
44 - name: cassandra-config-{{ $key | replace "." "-" }}
45 mountPath: /etc/cassandra/{{ $key }}
46 subPath: {{ $key }}
47 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000048 {{- if eq .Values.liveness.enabled true }}
49 livenessProbe:
50 exec:
51 command:
52 - /bin/bash
53 - -c
54 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
55 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
56 periodSeconds: {{ .Values.liveness.periodSeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000057 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
58 successThreshold: {{ .Values.liveness.successThreshold }}
59 failureThreshold: {{ .Values.liveness.failureThreshold }}
Joey Sullivanbec0c982019-06-11 10:53:16 -040060 {{ end }}
prpatelafedf2c2018-09-07 15:28:38 +000061 readinessProbe:
62 exec:
63 command:
64 - /bin/bash
65 - -c
66 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
67 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000068 periodSeconds: {{ .Values.readiness.periodSeconds }}
69 timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
70 successThreshold: {{ .Values.readiness.successThreshold }}
71 failureThreshold: {{ .Values.readiness.failureThreshold }}
prpatelafedf2c2018-09-07 15:28:38 +000072 env:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000073 {{- $seed_size := default 1 .Values.replicaCount | int -}}
74 {{- $global := . }}
75 - name: CASSANDRA_SEEDS
76 {{- if .Values.hostNetwork }}
77 value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
78 {{- else }}
79 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 }}"
80 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000081 - name: MAX_HEAP_SIZE
82 value: {{ .Values.config.heap.max }}
83 - name: HEAP_NEWSIZE
84 value: {{ .Values.config.heap.min }}
85 - name: JVM_OPTS
86 value: {{ .Values.config.jvmOpts | quote }}
87 - name: CASSANDRA_CLUSTER_NAME
88 value: {{ .Values.config.clusterName | quote }}
89 - name: CASSANDRA_DC
90 value: {{ .Values.config.dataCenter | quote }}
91 - name: CASSANDRA_RACK
92 value: {{ .Values.config.rackName | quote }}
93 - name: CASSANDRA_AUTO_BOOTSTRAP
94 value: {{ .Values.config.autoBootstrap | quote }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000095 - name: CASSANDRA_START_RPC
96 value: {{ default "true" .Values.config.start_rpc | quote }}
97 - name: CASSANDRA_ENDPOINT_SNITCH
Mahendra Raghuwanshia9a4f312019-03-19 06:05:47 +000098 value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
mahendrr8b20f772019-05-03 06:50:10 +000099 - name: CASSANDRA_AUTHENTICATOR
100 value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000101 - name: POD_IP
102 valueFrom:
103 fieldRef:
104 fieldPath: status.podIP
prpatelafedf2c2018-09-07 15:28:38 +0000105 lifecycle:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000106 preStop:
prpatelafedf2c2018-09-07 15:28:38 +0000107 exec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000108 {{- if not .Values.persistence.enabled }}
109 command: ["/bin/sh", "-c", "exec nodetool decommission"]
110 {{- else }}
111 command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
112 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000113 resources:
114{{ toYaml .Values.resources | indent 10 }}
115 {{- if .Values.nodeSelector }}
116 nodeSelector:
117{{ toYaml .Values.nodeSelector | indent 8 }}
118 {{- end -}}
119 {{- if .Values.affinity }}
120 affinity:
121{{ toYaml .Values.affinity | indent 8 }}
122 {{- end }}
123 volumes:
124 - name: localtime
125 hostPath:
126 path: /etc/localtime
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000127 {{- range $key, $value := .Values.configOverrides }}
128 - name: cassandra-config-{{ $key | replace "." "-" }}
prpatelafedf2c2018-09-07 15:28:38 +0000129 configMap:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000130 name: {{ include "common.fullname" . }}-configOverrides
131 {{- end }}
mahendrr8b20f772019-05-03 06:50:10 +0000132 - name: cassandra-entrypoint
133 configMap:
134 name: {{ include "common.fullname" . }}-entrypoint
135 defaultMode: 0755
prpatelafedf2c2018-09-07 15:28:38 +0000136 {{- if not .Values.persistence.enabled }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100137 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000138 emptyDir: {}
139 {{- else }}
140 volumeClaimTemplates:
141 - metadata:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100142 name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000143 labels:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100144 name: {{ include "common.fullname" . }}
145 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100146 release: "{{ include "common.release" . }}"
prpatelafedf2c2018-09-07 15:28:38 +0000147 heritage: "{{ .Release.Service }}"
prpatelafedf2c2018-09-07 15:28:38 +0000148 spec:
149 accessModes:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100150 {{- if .Values.backup.enabled }}
151 - ReadWriteMany
152 {{- else }}
153 - ReadWriteOnce
154 {{- end }}
155 storageClassName: {{ include "common.storageClass" . }}
prpatelafedf2c2018-09-07 15:28:38 +0000156 resources:
157 requests:
158 storage: {{ .Values.persistence.size | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000159 {{- end }}