blob: 1a00b3c1d725b0801e1476bdcf7bb3a521accb2a [file] [log] [blame]
vagrant1a3a3552018-03-10 23:56:32 +00001apiVersion: apps/v1beta1
2kind: StatefulSet
3metadata:
4 name: {{ include "common.fullname" . }}
5 namespace: {{ include "common.namespace" . }}
6 labels:
7 app: {{ include "common.name" . }}
8 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9 release: {{ .Release.Name }}
10 heritage: {{ .Release.Service }}
11spec:
BorislavG26b650f2018-05-13 17:11:01 +000012 serviceName: {{ include "common.servicename" . }}
vagrant1a3a3552018-03-10 23:56:32 +000013 replicas: {{ .Values.replicaCount }}
14 podManagementPolicy: {{ .Values.podManagementPolicy }}
15 updateStrategy:
16 type: {{ .Values.updateStrategy.type }}
17 template:
18 metadata:
19 labels:
20 app: {{ include "common.name" . }}
21 release: {{ .Release.Name }}
22 name: {{ include "common.name" . }}
23 spec:
24 containers:
25 - name: {{ include "common.name" . }}
26 image: {{ .Values.image }}
27 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
28 ports:
29 - containerPort: {{ .Values.service.internalPort }}
30 - containerPort: {{ .Values.service.internalPort2 }}
31 - containerPort: {{ .Values.service.internalPort3 }}
vagrant1a3a3552018-03-10 23:56:32 +000032 {{- if eq .Values.liveness.enabled true }}
33 livenessProbe:
34 exec:
35 command:
36 - /bin/bash
37 - -c
38 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
39 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
40 periodSeconds: {{ .Values.liveness.periodSeconds }}
41 {{ end -}}
42 readinessProbe:
43 exec:
44 command:
45 - /bin/bash
46 - -c
47 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
48 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
49 timeoutSeconds: {{ .Values.liveness.periodSeconds }}
50 lifecycle:
51 preStop:
52 exec:
53 command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
54 env:
55 {{- $seed_size := default 1 .Values.replicaCount | int -}}
56 {{- $global := . }}
57 - name: MAX_HEAP_SIZE
58 value: {{ .Values.config.heap.max }}
59 - name: HEAP_NEWSIZE
60 value: {{ .Values.config.heap.min }}
61 - name: CASSANDRA_SEEDS
BorislavG26b650f2018-05-13 17:11:01 +000062 value: "{{- range $i, $e := until $seed_size }}{{ template "common.fullname" $global }}-{{ $i }}.{{ include "common.servicename" $global }},{{- end }}"
vagrant1a3a3552018-03-10 23:56:32 +000063 - name: JVM_OPTS
64 value: {{ .Values.config.jvmOpts | quote }}
65 - name: CASSANDRA_CLUSTER_NAME
66 value: {{ .Values.config.clusterName | quote }}
67 - name: CASSANDRA_DC
68 value: {{ .Values.config.dataCenter | quote }}
69 - name: CASSANDRA_RACK
70 value: {{ .Values.config.rackName | quote }}
71 - name: CASSANDRA_AUTO_BOOTSTRAP
72 value: {{ .Values.config.autoBootstrap | quote }}
73 - name: POD_IP
74 valueFrom:
75 fieldRef:
76 fieldPath: status.podIP
77 volumeMounts:
78 - name: cassandra-data
Daniel Silverthornfc1a1882018-05-01 18:51:42 +000079 mountPath: /var/lib/cassandra
vagrant1a3a3552018-03-10 23:56:32 +000080 resources:
81{{ toYaml .Values.resources | indent 10 }}
82 {{- if .Values.nodeSelector }}
83 nodeSelector:
84{{ toYaml .Values.nodeSelector | indent 8 }}
85 {{- end -}}
86 {{- if .Values.affinity }}
87 affinity:
88{{ toYaml .Values.affinity | indent 8 }}
89 {{- end }}
90 volumes:
91 - name: localtime
92 hostPath:
93 path: /etc/localtime
94 {{- if not .Values.persistence.enabled }}
95 - name: cassandra-data
96 emptyDir: {}
97 {{- else }}
98 volumeClaimTemplates:
99 - metadata:
100 name: cassandra-data
101 labels:
102 app: {{ template "common.fullname" . }}
103 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
104 release: "{{ .Release.Name }}"
105 heritage: "{{ .Release.Service }}"
106 annotations:
107 volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass }}
108 spec:
109 accessModes:
110 - {{ .Values.persistence.accessMode | quote }}
111 resources:
112 requests:
113 storage: {{ .Values.persistence.size | quote }}
114 {{- end }}