prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 1 | # 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 | |
| 15 | apiVersion: apps/v1beta1 |
| 16 | kind: StatefulSet |
| 17 | metadata: |
| 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 }} |
| 25 | spec: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 26 | selector: |
| 27 | matchLabels: |
| 28 | app: {{ include "common.name" . }} |
| 29 | release: {{ .Release.Name }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 30 | 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" . }} |
| 39 | release: {{ .Release.Name }} |
| 40 | name: {{ include "common.name" . }} |
| 41 | spec: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 42 | hostNetwork: {{ .Values.hostNetwork }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 43 | containers: |
| 44 | - name: {{ include "common.name" . }} |
| 45 | image: {{ .Values.image }} |
| 46 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 47 | ports: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 48 | {{- range $index, $ports := .Values.service.ports }} |
| 49 | - containerPort: {{ $ports.port }} |
| 50 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 51 | volumeMounts: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 52 | - name: cassandra-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 53 | mountPath: /var/lib/cassandra |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 54 | - name: localtime |
| 55 | mountPath: /etc/localtime |
| 56 | readOnly: true |
| 57 | {{- range $key, $value := .Values.configOverrides }} |
| 58 | - name: cassandra-config-{{ $key | replace "." "-" }} |
| 59 | mountPath: /etc/cassandra/{{ $key }} |
| 60 | subPath: {{ $key }} |
| 61 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 62 | {{- if eq .Values.liveness.enabled true }} |
| 63 | livenessProbe: |
| 64 | exec: |
| 65 | command: |
| 66 | - /bin/bash |
| 67 | - -c |
| 68 | - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }' |
| 69 | initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} |
| 70 | periodSeconds: {{ .Values.liveness.periodSeconds }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 71 | timeoutSeconds: {{ .Values.liveness.timeoutSeconds }} |
| 72 | successThreshold: {{ .Values.liveness.successThreshold }} |
| 73 | failureThreshold: {{ .Values.liveness.failureThreshold }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 74 | {{ end -}} |
| 75 | readinessProbe: |
| 76 | exec: |
| 77 | command: |
| 78 | - /bin/bash |
| 79 | - -c |
| 80 | - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }' |
| 81 | initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 82 | periodSeconds: {{ .Values.readiness.periodSeconds }} |
| 83 | timeoutSeconds: {{ .Values.readiness.timeoutSeconds }} |
| 84 | successThreshold: {{ .Values.readiness.successThreshold }} |
| 85 | failureThreshold: {{ .Values.readiness.failureThreshold }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 86 | env: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 87 | {{- $seed_size := default 1 .Values.replicaCount | 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 "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 }}" |
| 94 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 95 | - name: MAX_HEAP_SIZE |
| 96 | value: {{ .Values.config.heap.max }} |
| 97 | - name: HEAP_NEWSIZE |
| 98 | value: {{ .Values.config.heap.min }} |
| 99 | - name: JVM_OPTS |
| 100 | value: {{ .Values.config.jvmOpts | quote }} |
| 101 | - name: CASSANDRA_CLUSTER_NAME |
| 102 | value: {{ .Values.config.clusterName | quote }} |
| 103 | - name: CASSANDRA_DC |
| 104 | value: {{ .Values.config.dataCenter | quote }} |
| 105 | - name: CASSANDRA_RACK |
| 106 | value: {{ .Values.config.rackName | quote }} |
| 107 | - name: CASSANDRA_AUTO_BOOTSTRAP |
| 108 | value: {{ .Values.config.autoBootstrap | quote }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 109 | - name: CASSANDRA_START_RPC |
| 110 | value: {{ default "true" .Values.config.start_rpc | quote }} |
| 111 | - name: CASSANDRA_ENDPOINT_SNITCH |
| 112 | value: {{ default "SimpleSnitch" .Values.config.endpoint_snitch | quote }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 113 | - name: POD_IP |
| 114 | valueFrom: |
| 115 | fieldRef: |
| 116 | fieldPath: status.podIP |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 117 | lifecycle: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 118 | preStop: |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 119 | exec: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 120 | {{- if not .Values.persistence.enabled }} |
| 121 | command: ["/bin/sh", "-c", "exec nodetool decommission"] |
| 122 | {{- else }} |
| 123 | command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"] |
| 124 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 125 | resources: |
| 126 | {{ toYaml .Values.resources | indent 10 }} |
| 127 | {{- if .Values.nodeSelector }} |
| 128 | nodeSelector: |
| 129 | {{ toYaml .Values.nodeSelector | indent 8 }} |
| 130 | {{- end -}} |
| 131 | {{- if .Values.affinity }} |
| 132 | affinity: |
| 133 | {{ toYaml .Values.affinity | indent 8 }} |
| 134 | {{- end }} |
| 135 | volumes: |
| 136 | - name: localtime |
| 137 | hostPath: |
| 138 | path: /etc/localtime |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 139 | {{- range $key, $value := .Values.configOverrides }} |
| 140 | - name: cassandra-config-{{ $key | replace "." "-" }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 141 | configMap: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 142 | name: {{ include "common.fullname" . }}-configOverrides |
| 143 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 144 | {{- if not .Values.persistence.enabled }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 145 | - name: cassandra-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 146 | emptyDir: {} |
| 147 | {{- else }} |
| 148 | volumeClaimTemplates: |
| 149 | - metadata: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 150 | name: cassandra-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 151 | labels: |
| 152 | app: {{ template "common.fullname" . }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 153 | release: "{{ .Release.Name }}" |
| 154 | heritage: "{{ .Release.Service }}" |
| 155 | annotations: |
| 156 | volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass }} |
| 157 | spec: |
| 158 | accessModes: |
| 159 | - {{ .Values.persistence.accessMode | quote }} |
| 160 | resources: |
| 161 | requests: |
| 162 | storage: {{ .Values.persistence.size | quote }} |
Alexis de Talhouët | 634b455 | 2018-10-28 21:56:33 -0400 | [diff] [blame] | 163 | selector: |
| 164 | matchLabels: |
| 165 | release: "{{ .Release.Name }}" |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 166 | {{- end }} |