blob: b737a8f960f52727828e89816b100bdd53ff70d8 [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
15apiVersion: apps/v1beta1
16kind: StatefulSet
17metadata:
18 name: {{ include "common.fullname" . }}
19 namespace: {{ include "common.namespace" . }}
20 labels:
21 app: {{ include "common.name" . }}
22 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010023 release: {{ include "common.release" . }}
prpatelafedf2c2018-09-07 15:28:38 +000024 heritage: {{ .Release.Service }}
25spec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000026 selector:
27 matchLabels:
28 app: {{ include "common.name" . }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010029 release: {{ include "common.release" . }}
prpatelafedf2c2018-09-07 15:28:38 +000030 serviceName: {{ include "common.servicename" . }}
31 replicas: {{ .Values.replicaCount }}
32 podManagementPolicy: {{ .Values.podManagementPolicy }}
33 updateStrategy:
34 type: {{ .Values.updateStrategy.type }}
35 template:
36 metadata:
37 labels:
38 app: {{ include "common.name" . }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010039 release: {{ include "common.release" . }}
prpatelafedf2c2018-09-07 15:28:38 +000040 name: {{ include "common.name" . }}
41 spec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000042 hostNetwork: {{ .Values.hostNetwork }}
prpatelafedf2c2018-09-07 15:28:38 +000043 containers:
44 - name: {{ include "common.name" . }}
45 image: {{ .Values.image }}
46 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
47 ports:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000048 {{- range $index, $ports := .Values.service.ports }}
49 - containerPort: {{ $ports.port }}
50 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000051 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010052 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +000053 mountPath: /var/lib/cassandra
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000054 - name: localtime
55 mountPath: /etc/localtime
56 readOnly: true
mahendrr8b20f772019-05-03 06:50:10 +000057 - name: cassandra-entrypoint
58 mountPath: /docker-entrypoint.sh
59 subPath: docker-entrypoint.sh
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000060 {{- range $key, $value := .Values.configOverrides }}
61 - name: cassandra-config-{{ $key | replace "." "-" }}
62 mountPath: /etc/cassandra/{{ $key }}
63 subPath: {{ $key }}
64 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000065 {{- if eq .Values.liveness.enabled true }}
66 livenessProbe:
67 exec:
68 command:
69 - /bin/bash
70 - -c
71 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
72 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
73 periodSeconds: {{ .Values.liveness.periodSeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000074 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
75 successThreshold: {{ .Values.liveness.successThreshold }}
76 failureThreshold: {{ .Values.liveness.failureThreshold }}
Joey Sullivanbec0c982019-06-11 10:53:16 -040077 {{ end }}
prpatelafedf2c2018-09-07 15:28:38 +000078 readinessProbe:
79 exec:
80 command:
81 - /bin/bash
82 - -c
83 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
84 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000085 periodSeconds: {{ .Values.readiness.periodSeconds }}
86 timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
87 successThreshold: {{ .Values.readiness.successThreshold }}
88 failureThreshold: {{ .Values.readiness.failureThreshold }}
prpatelafedf2c2018-09-07 15:28:38 +000089 env:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +000090 {{- $seed_size := default 1 .Values.replicaCount | int -}}
91 {{- $global := . }}
92 - name: CASSANDRA_SEEDS
93 {{- if .Values.hostNetwork }}
94 value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
95 {{- else }}
96 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 }}"
97 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +000098 - name: MAX_HEAP_SIZE
99 value: {{ .Values.config.heap.max }}
100 - name: HEAP_NEWSIZE
101 value: {{ .Values.config.heap.min }}
102 - name: JVM_OPTS
103 value: {{ .Values.config.jvmOpts | quote }}
104 - name: CASSANDRA_CLUSTER_NAME
105 value: {{ .Values.config.clusterName | quote }}
106 - name: CASSANDRA_DC
107 value: {{ .Values.config.dataCenter | quote }}
108 - name: CASSANDRA_RACK
109 value: {{ .Values.config.rackName | quote }}
110 - name: CASSANDRA_AUTO_BOOTSTRAP
111 value: {{ .Values.config.autoBootstrap | quote }}
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000112 - name: CASSANDRA_START_RPC
113 value: {{ default "true" .Values.config.start_rpc | quote }}
114 - name: CASSANDRA_ENDPOINT_SNITCH
Mahendra Raghuwanshia9a4f312019-03-19 06:05:47 +0000115 value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }}
mahendrr8b20f772019-05-03 06:50:10 +0000116 - name: CASSANDRA_AUTHENTICATOR
117 value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000118 - name: POD_IP
119 valueFrom:
120 fieldRef:
121 fieldPath: status.podIP
prpatelafedf2c2018-09-07 15:28:38 +0000122 lifecycle:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000123 preStop:
prpatelafedf2c2018-09-07 15:28:38 +0000124 exec:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000125 {{- if not .Values.persistence.enabled }}
126 command: ["/bin/sh", "-c", "exec nodetool decommission"]
127 {{- else }}
128 command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
129 {{- end }}
prpatelafedf2c2018-09-07 15:28:38 +0000130 resources:
131{{ toYaml .Values.resources | indent 10 }}
132 {{- if .Values.nodeSelector }}
133 nodeSelector:
134{{ toYaml .Values.nodeSelector | indent 8 }}
135 {{- end -}}
136 {{- if .Values.affinity }}
137 affinity:
138{{ toYaml .Values.affinity | indent 8 }}
139 {{- end }}
140 volumes:
141 - name: localtime
142 hostPath:
143 path: /etc/localtime
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000144 {{- range $key, $value := .Values.configOverrides }}
145 - name: cassandra-config-{{ $key | replace "." "-" }}
prpatelafedf2c2018-09-07 15:28:38 +0000146 configMap:
Mahendra Raghuwanshif59d9252019-02-20 06:54:46 +0000147 name: {{ include "common.fullname" . }}-configOverrides
148 {{- end }}
mahendrr8b20f772019-05-03 06:50:10 +0000149 - name: cassandra-entrypoint
150 configMap:
151 name: {{ include "common.fullname" . }}-entrypoint
152 defaultMode: 0755
prpatelafedf2c2018-09-07 15:28:38 +0000153 {{- if not .Values.persistence.enabled }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100154 - name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000155 emptyDir: {}
156 {{- else }}
157 volumeClaimTemplates:
158 - metadata:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100159 name: {{ include "common.fullname" . }}-data
prpatelafedf2c2018-09-07 15:28:38 +0000160 labels:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100161 name: {{ include "common.fullname" . }}
162 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100163 release: "{{ include "common.release" . }}"
prpatelafedf2c2018-09-07 15:28:38 +0000164 heritage: "{{ .Release.Service }}"
prpatelafedf2c2018-09-07 15:28:38 +0000165 spec:
166 accessModes:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100167 {{- if .Values.backup.enabled }}
168 - ReadWriteMany
169 {{- else }}
170 - ReadWriteOnce
171 {{- end }}
172 storageClassName: {{ include "common.storageClass" . }}
prpatelafedf2c2018-09-07 15:28:38 +0000173 resources:
174 requests:
175 storage: {{ .Values.persistence.size | quote }}
prpatelafedf2c2018-09-07 15:28:38 +0000176 {{- end }}