Sync up to the latest it/dep commit.
[ric-plt/ric-dep.git] / helm / infrastructure / subcharts / kong / charts / cassandra / templates / statefulset.yaml
1 apiVersion: apps/v1
2 kind: StatefulSet
3 metadata:
4   name: {{ template "cassandra.fullname" . }}
5   labels:
6     app: {{ template "cassandra.name" . }}
7     chart: {{ template "cassandra.chart" . }}
8     release: {{ .Release.Name }}
9     heritage: {{ .Release.Service }}
10 spec:
11   selector:
12     matchLabels:
13       app: {{ template "cassandra.name" . }}
14       release: {{ .Release.Name }}
15   serviceName: {{ template "cassandra.fullname" . }}
16   replicas: {{ .Values.config.cluster_size }}
17   podManagementPolicy: {{ .Values.podManagementPolicy }}
18   updateStrategy:
19     type: {{ .Values.updateStrategy.type }}
20   template:
21     metadata:
22       labels:
23         app: {{ template "cassandra.name" . }}
24         release: {{ .Release.Name }}
25 {{- if .Values.podLabels }}
26 {{ toYaml .Values.podLabels | indent 8 }}
27 {{- end }}
28 {{- if .Values.podAnnotations }}
29       annotations:
30 {{ toYaml .Values.podAnnotations | indent 8 }}
31 {{- end }}
32     spec:
33       hostNetwork: {{ .Values.hostNetwork }}
34 {{- if .Values.selector }}
35 {{ toYaml .Values.selector | indent 6 }}
36 {{- end }}
37       {{- if .Values.securityContext.enabled }}
38       securityContext:
39         fsGroup: {{ .Values.securityContext.fsGroup }}
40         runAsUser: {{ .Values.securityContext.runAsUser }}
41       {{- end }}
42 {{- if .Values.affinity }}
43       affinity:
44 {{ toYaml .Values.affinity | indent 8 }}
45 {{- end }}
46 {{- if .Values.tolerations }}
47       tolerations:
48 {{ toYaml .Values.tolerations | indent 8 }}
49 {{- end }}
50       containers:
51 {{- if .Values.exporter.enabled }}
52       - name: cassandra-exporter
53         image: "{{ .Values.exporter.image.repo }}:{{ .Values.exporter.image.tag }}"
54         env:
55           - name: CASSANDRA_EXPORTER_CONFIG_listenPort
56             value: {{ .Values.exporter.port | quote }}
57           - name: JVM_OPTS
58             value: {{ .Values.exporter.jvmOpts | quote }}
59         ports:
60           - name: metrics
61             containerPort: {{ .Values.exporter.port }}
62             protocol: TCP
63           - name: jmx
64             containerPort: 5555
65         livenessProbe:
66           tcpSocket:
67             port: {{ .Values.exporter.port }}
68         readinessProbe:
69           httpGet:
70             path: /metrics
71             port: {{ .Values.exporter.port }}
72           initialDelaySeconds: 20
73           timeoutSeconds: 45
74 {{- end }}
75       - name: {{ template "cassandra.fullname" . }}
76         image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
77         imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
78 {{- if .Values.commandOverrides }}
79         command: {{ .Values.commandOverrides }}
80 {{- end }}
81 {{- if .Values.argsOverrides }}
82         args: {{ .Values.argsOverrides }}
83 {{- end }}
84         resources:
85 {{ toYaml .Values.resources | indent 10 }}
86         env:
87         {{- $seed_size := default 1 .Values.config.seed_size | int -}}
88         {{- $global := . }}
89         - name: CASSANDRA_SEEDS
90           {{- if .Values.hostNetwork }}
91           value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }}
92           {{- else }}
93           value: "{{- range $i, $e := until $seed_size }}{{ template "cassandra.fullname" $global }}-{{ $i }}.{{ template "cassandra.fullname" $global }}.{{ $global.Release.Namespace }}.svc.{{ $global.Values.config.cluster_domain }}{{- if (lt ( add1 $i ) $seed_size ) }},{{- end }}{{- end }}"
94           {{- end }}     
95         - name: MAX_HEAP_SIZE
96           value: {{ default "8192M" .Values.config.max_heap_size | quote }}
97         - name: HEAP_NEWSIZE
98           value: {{ default "200M" .Values.config.heap_new_size | quote }}
99         - name: CASSANDRA_ENDPOINT_SNITCH
100           value: {{ default "SimpleSnitch" .Values.config.endpoint_snitch | quote }}
101         - name: CASSANDRA_CLUSTER_NAME
102           value: {{ default "Cassandra" .Values.config.cluster_name | quote }}
103         - name: CASSANDRA_DC
104           value: {{ default "DC1" .Values.config.dc_name | quote }}
105         - name: CASSANDRA_RACK
106           value: {{ default "RAC1" .Values.config.rack_name | quote }}
107         - name: CASSANDRA_START_RPC
108           value: {{ default "false" .Values.config.start_rpc | quote }}
109         - name: POD_IP
110           valueFrom:
111             fieldRef:
112               fieldPath: status.podIP
113         {{- range $key, $value := .Values.env }}
114         - name: {{ $key | quote }}
115           value: {{ $value | quote }}
116         {{- end }}
117         livenessProbe:
118           exec:
119             command: [ "/bin/sh", "-c", "nodetool status" ]
120           initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
121           periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
122           timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
123           successThreshold: {{ .Values.livenessProbe.successThreshold }}
124           failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
125         readinessProbe:
126           exec:
127             command: [ "/bin/sh", "-c", "nodetool status | grep -E \"^UN\\s+${POD_IP}\"" ]
128           initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
129           periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
130           timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
131           successThreshold: {{ .Values.readinessProbe.successThreshold }}
132           failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
133         ports:
134         - name: intra
135           containerPort: 7000
136         - name: tls
137           containerPort: 7001
138         - name: jmx
139           containerPort: 7199
140         - name: cql
141           containerPort: {{ default 9042 .Values.config.ports.cql }}
142         - name: thrift
143           containerPort: {{ default 9160 .Values.config.ports.thrift }}
144         {{- if .Values.config.ports.agent }}
145         - name: agent
146           containerPort: {{ .Values.config.ports.agent }}
147         {{- end }}
148         volumeMounts:
149         - name: data
150           mountPath: /var/lib/cassandra
151 {{- range $key, $value := .Values.configOverrides }}
152         - name: cassandra-config-{{ $key | replace "." "-" }}
153           mountPath: /etc/cassandra/{{ $key }}
154           subPath: {{ $key }}
155 {{- end }}
156         {{- if not .Values.persistence.enabled }}
157         lifecycle:
158           preStop:
159             exec:
160               command: ["/bin/sh", "-c", "exec nodetool decommission"]
161         {{- end }}
162       terminationGracePeriodSeconds: {{ default 30 .Values.podSettings.terminationGracePeriodSeconds }}
163       {{- if .Values.image.pullSecrets }}
164       imagePullSecrets:
165         - name: {{ .Values.image.pullSecrets }}
166       {{- end }}
167 {{- if or .Values.configOverrides (not .Values.persistence.enabled) }}
168       volumes:
169 {{- end }}
170 {{- range $key, $value := .Values.configOverrides }}
171       - configMap:
172           name: cassandra
173         name: cassandra-config-{{ $key | replace "." "-" }}
174 {{- end }}
175 {{- if not .Values.persistence.enabled }}
176       - name: data
177         emptyDir: {}
178 {{- else }}
179   volumeClaimTemplates:
180   - metadata:
181       name: data
182       labels:
183         app: {{ template "cassandra.name" . }}
184         chart: {{ template "cassandra.chart" . }}
185         release: {{ .Release.Name }}
186         heritage: {{ .Release.Service }}
187     spec:
188       accessModes:
189         - {{ .Values.persistence.accessMode | quote }}
190       resources:
191         requests:
192           storage: {{ .Values.persistence.size | quote }}
193     {{- if .Values.persistence.storageClass }}
194     {{- if (eq "-" .Values.persistence.storageClass) }}
195       storageClassName: ""
196     {{- else }}
197       storageClassName: "{{ .Values.persistence.storageClass }}"
198     {{- end }}
199     {{- end }}
200 {{- end }}