blob: b6bd8f6aa787c725d44e408ae76695aa7248e808 [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 "+" "_" }}
23 release: {{ .Release.Name }}
24 heritage: {{ .Release.Service }}
25spec:
26 serviceName: {{ include "common.servicename" . }}
27 replicas: {{ .Values.replicaCount }}
28 podManagementPolicy: {{ .Values.podManagementPolicy }}
29 updateStrategy:
30 type: {{ .Values.updateStrategy.type }}
31 template:
32 metadata:
33 labels:
34 app: {{ include "common.name" . }}
35 release: {{ .Release.Name }}
36 name: {{ include "common.name" . }}
37 spec:
38 containers:
39 - name: {{ include "common.name" . }}
40 image: {{ .Values.image }}
41 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
42 ports:
43 - containerPort: {{ .Values.service.internalPort }}
44 - containerPort: {{ .Values.service.internalPort2 }}
45 - containerPort: {{ .Values.service.internalPort3 }}
46 - containerPort: {{ .Values.service.internalPort4 }}
47 - containerPort: {{ .Values.service.internalPort5 }}
48 volumeMounts:
49 - name: {{ .Values.service.name }}
50 mountPath: /var/lib/cassandra
51 {{ if eq .Values.configmapping true }}
52 - name: {{ .Values.service.name }}-docker-entry-initd
53 mountPath: /{{ .Values.service.name }}-docker-entrypoint-initdb.d/cassandra.cql
54 subPath: cassandra.cql
55 {{ end }}
56 {{- if eq .Values.liveness.enabled true }}
57 livenessProbe:
58 exec:
59 command:
60 - /bin/bash
61 - -c
62 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
63 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
64 periodSeconds: {{ .Values.liveness.periodSeconds }}
65 {{ end -}}
66 readinessProbe:
67 exec:
68 command:
69 - /bin/bash
70 - -c
71 - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
72 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
73 timeoutSeconds: {{ .Values.liveness.periodSeconds }}
74 env:
75 {{- $seed_size := default 1 .Values.replicaCount | int -}}
76 {{- $global := . }}
77 - name: MAX_HEAP_SIZE
78 value: {{ .Values.config.heap.max }}
79 - name: HEAP_NEWSIZE
80 value: {{ .Values.config.heap.min }}
81 - name: JVM_OPTS
82 value: {{ .Values.config.jvmOpts | quote }}
83 - name: CASSANDRA_CLUSTER_NAME
84 value: {{ .Values.config.clusterName | quote }}
85 - name: CASSANDRA_DC
86 value: {{ .Values.config.dataCenter | quote }}
87 - name: CASSANDRA_RACK
88 value: {{ .Values.config.rackName | quote }}
89 - name: CASSANDRA_AUTO_BOOTSTRAP
90 value: {{ .Values.config.autoBootstrap | quote }}
91 - name: POD_IP
92 valueFrom:
93 fieldRef:
94 fieldPath: status.podIP
95 {{ if eq .Values.configmapping true }}
96 lifecycle:
97 postStart:
98 exec:
99 command:
100 - /bin/sh
101 - -c
102 - >
103 /bin/sleep {{ .Values.readiness.initialDelaySeconds }};
104 cd /{{ .Values.service.name }}-docker-entrypoint-initdb.d;
105 cqlsh -u root -p root -f cassandra.cql
106 {{ end }}
107 resources:
108{{ toYaml .Values.resources | indent 10 }}
109 {{- if .Values.nodeSelector }}
110 nodeSelector:
111{{ toYaml .Values.nodeSelector | indent 8 }}
112 {{- end -}}
113 {{- if .Values.affinity }}
114 affinity:
115{{ toYaml .Values.affinity | indent 8 }}
116 {{- end }}
117 volumes:
118 - name: localtime
119 hostPath:
120 path: /etc/localtime
121 {{ if eq .Values.configmapping true }}
122 - name: {{ .Values.service.name }}-docker-entry-initd
123 configMap:
124 name: {{ .Values.service.name }}-docker-entry-initd
125 {{ end }}
126 {{- if not .Values.persistence.enabled }}
127 - name: {{ .Values.service.name }}
128 emptyDir: {}
129 {{- else }}
130 volumeClaimTemplates:
131 - metadata:
132 name: {{ .Values.service.name }}
133 labels:
134 app: {{ template "common.fullname" . }}
135 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
136 release: "{{ .Release.Name }}"
137 heritage: "{{ .Release.Service }}"
138 annotations:
139 volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass }}
140 spec:
141 accessModes:
142 - {{ .Values.persistence.accessMode | quote }}
143 resources:
144 requests:
145 storage: {{ .Values.persistence.size | quote }}
146 {{- end }}