Merge "[COMMON][ES] Simplify cert retrieval script"
[oom.git] / kubernetes / common / music / components / music-cassandra / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2019 AT&T, Amdocs, Bell Canada, Orange
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.
15 */}}
16
17
18 apiVersion: apps/v1
19 kind: StatefulSet
20 metadata:
21   name: {{ include "common.fullname" . }}
22   namespace: {{ include "common.namespace" . }}
23   labels:
24     app: {{ include "common.name" . }}
25     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26     release: {{ include "common.release" . }}
27     heritage: {{ .Release.Service }}
28 spec:
29   serviceName: {{ include "common.servicename" . }}
30   replicas: {{ .Values.replicaCount }}
31   selector:
32     matchLabels:
33       app: {{ include "common.name" . }}
34   podManagementPolicy: {{ .Values.podManagementPolicy }}
35   updateStrategy:
36     type: {{ .Values.updateStrategy.type }}
37   template:
38     metadata:
39       labels:
40         app: {{ include "common.name" . }}
41         release: {{ include "common.release" . }}
42       name: {{ include "common.name" . }}
43     spec:
44       containers:
45       - name: {{ include "common.name" . }}
46         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
47         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
48         ports:
49         - containerPort: {{ .Values.service.internalPort }}
50         - containerPort: {{ .Values.service.internalPort2 }}
51         - containerPort: {{ .Values.service.internalPort3 }}
52         {{- if eq .Values.liveness.enabled true }}
53         livenessProbe:
54           exec:
55             command:
56             - /bin/bash
57             - -c
58             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
59           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
60           periodSeconds: {{ .Values.liveness.periodSeconds }}
61           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
62           successThreshold: {{ .Values.liveness.successThreshold }}
63           failureThreshold: {{ .Values.liveness.failureThreshold }}
64         {{ end -}}
65         readinessProbe:
66           exec:
67             command:
68             - /bin/bash
69             - -c
70             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
71           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
72           periodSeconds: {{ .Values.readiness.periodSeconds }}
73           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
74           successThreshold: {{ .Values.readiness.successThreshold }}
75           failureThreshold: {{ .Values.readiness.failureThreshold }}
76         startupProbe:
77           exec:
78             command:
79             - /bin/bash
80             - -c
81             - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
82           initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
83           periodSeconds: {{ .Values.startup.periodSeconds }}
84           timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
85           successThreshold: {{ .Values.startup.successThreshold }}
86           failureThreshold: {{ .Values.startup.failureThreshold }}
87         lifecycle:
88           preStop:
89             exec:
90               command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
91         env:
92         {{- $seed_size := default 1 .Values.replicaCount | int -}}
93         {{- $global := . }}
94           - name: MAX_HEAP_SIZE
95             value: {{ .Values.config.heap.max }}
96           - name: HEAP_NEWSIZE
97             value: {{ .Values.config.heap.min }}
98           - name: CASSANDRA_SEEDS
99             value: "{{- range $i, $e := until $seed_size }}{{ template "common.fullname" $global }}-{{ $i }}.{{ include "common.servicename" $global }}{{- if (lt ( add 1 $i ) $seed_size ) }},{{- end }}{{- end }}"
100           - name: JVM_OPTS
101             value: {{ .Values.config.jvmOpts | quote }}
102           - name: CASSANDRA_CLUSTER_NAME
103             value: {{ .Values.config.clusterName | quote }}
104           - name: CASSANDRA_DC
105             value: {{ .Values.config.dataCenter | quote }}
106           - name: CASSANDRA_RACK
107             value: {{ .Values.config.rackName | quote }}
108           - name: CASSANDRA_AUTO_BOOTSTRAP
109             value: {{ .Values.config.autoBootstrap | quote }}
110           - name: POD_IP
111             valueFrom:
112               fieldRef:
113                 fieldPath: status.podIP
114 {{- if .Values.persistence.enabled }}
115         volumeMounts:
116           - name: {{ include "common.fullname" . }}-data
117             mountPath: /var/lib/cassandra
118 {{- end }}
119         resources:
120 {{ include "common.resources" . | indent 12 }}
121       volumes:
122       - name: localtime
123         hostPath:
124           path: /etc/localtime
125 {{- if .Values.persistence.enabled }}
126   volumeClaimTemplates:
127   - metadata:
128       name: {{ include "common.fullname" . }}-data
129       labels:
130         name: {{ include "common.fullname" . }}
131         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
132         release: "{{ include "common.release" . }}"
133         heritage: "{{ .Release.Service }}"
134     spec:
135       accessModes:
136       - {{ .Values.persistence.accessMode | quote }}
137       storageClassName: {{ include "common.storageClass" . }}
138       resources:
139         requests:
140           storage: {{ .Values.persistence.size | quote }}
141 {{- end }}