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 | |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 15 | apiVersion: apps/v1 |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 16 | kind: StatefulSet |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 17 | metadata: {{- include "common.resourceMetadata" . | nindent 2 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 18 | spec: |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 19 | selector: {{- include "common.selectors" . | nindent 4 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 20 | serviceName: {{ include "common.servicename" . }} |
| 21 | replicas: {{ .Values.replicaCount }} |
| 22 | podManagementPolicy: {{ .Values.podManagementPolicy }} |
| 23 | updateStrategy: |
| 24 | type: {{ .Values.updateStrategy.type }} |
| 25 | template: |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 26 | metadata: {{- include "common.templateMetadata" . | nindent 6 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 27 | spec: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 28 | hostNetwork: {{ .Values.hostNetwork }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 29 | containers: |
| 30 | - name: {{ include "common.name" . }} |
| 31 | image: {{ .Values.image }} |
| 32 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 33 | ports: {{ include "common.containerPorts" . | nindent 8 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 34 | volumeMounts: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 35 | - name: {{ include "common.fullname" . }}-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 36 | mountPath: /var/lib/cassandra |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 37 | - name: localtime |
| 38 | mountPath: /etc/localtime |
| 39 | readOnly: true |
mahendrr | 8b20f77 | 2019-05-03 06:50:10 +0000 | [diff] [blame] | 40 | - name: cassandra-entrypoint |
| 41 | mountPath: /docker-entrypoint.sh |
| 42 | subPath: docker-entrypoint.sh |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 43 | {{- range $key, $value := .Values.configOverrides }} |
| 44 | - name: cassandra-config-{{ $key | replace "." "-" }} |
| 45 | mountPath: /etc/cassandra/{{ $key }} |
| 46 | subPath: {{ $key }} |
| 47 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 48 | {{- if eq .Values.liveness.enabled true }} |
| 49 | livenessProbe: |
| 50 | exec: |
| 51 | command: |
| 52 | - /bin/bash |
| 53 | - -c |
| 54 | - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }' |
| 55 | initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} |
| 56 | periodSeconds: {{ .Values.liveness.periodSeconds }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 57 | timeoutSeconds: {{ .Values.liveness.timeoutSeconds }} |
| 58 | successThreshold: {{ .Values.liveness.successThreshold }} |
| 59 | failureThreshold: {{ .Values.liveness.failureThreshold }} |
Joey Sullivan | bec0c98 | 2019-06-11 10:53:16 -0400 | [diff] [blame] | 60 | {{ end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 61 | readinessProbe: |
| 62 | exec: |
| 63 | command: |
| 64 | - /bin/bash |
| 65 | - -c |
| 66 | - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }' |
| 67 | initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 68 | periodSeconds: {{ .Values.readiness.periodSeconds }} |
| 69 | timeoutSeconds: {{ .Values.readiness.timeoutSeconds }} |
| 70 | successThreshold: {{ .Values.readiness.successThreshold }} |
| 71 | failureThreshold: {{ .Values.readiness.failureThreshold }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 72 | env: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 73 | {{- $seed_size := default 1 .Values.replicaCount | int -}} |
| 74 | {{- $global := . }} |
| 75 | - name: CASSANDRA_SEEDS |
| 76 | {{- if .Values.hostNetwork }} |
| 77 | value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }} |
| 78 | {{- else }} |
| 79 | 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 }}" |
| 80 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 81 | - name: MAX_HEAP_SIZE |
| 82 | value: {{ .Values.config.heap.max }} |
| 83 | - name: HEAP_NEWSIZE |
| 84 | value: {{ .Values.config.heap.min }} |
| 85 | - name: JVM_OPTS |
| 86 | value: {{ .Values.config.jvmOpts | quote }} |
| 87 | - name: CASSANDRA_CLUSTER_NAME |
| 88 | value: {{ .Values.config.clusterName | quote }} |
| 89 | - name: CASSANDRA_DC |
| 90 | value: {{ .Values.config.dataCenter | quote }} |
| 91 | - name: CASSANDRA_RACK |
| 92 | value: {{ .Values.config.rackName | quote }} |
| 93 | - name: CASSANDRA_AUTO_BOOTSTRAP |
| 94 | value: {{ .Values.config.autoBootstrap | quote }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 95 | - name: CASSANDRA_START_RPC |
| 96 | value: {{ default "true" .Values.config.start_rpc | quote }} |
| 97 | - name: CASSANDRA_ENDPOINT_SNITCH |
Mahendra Raghuwanshi | a9a4f31 | 2019-03-19 06:05:47 +0000 | [diff] [blame] | 98 | value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }} |
mahendrr | 8b20f77 | 2019-05-03 06:50:10 +0000 | [diff] [blame] | 99 | - name: CASSANDRA_AUTHENTICATOR |
| 100 | value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 101 | - name: POD_IP |
| 102 | valueFrom: |
| 103 | fieldRef: |
| 104 | fieldPath: status.podIP |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 105 | lifecycle: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 106 | preStop: |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 107 | exec: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 108 | {{- if not .Values.persistence.enabled }} |
| 109 | command: ["/bin/sh", "-c", "exec nodetool decommission"] |
| 110 | {{- else }} |
| 111 | command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"] |
| 112 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 113 | resources: |
| 114 | {{ toYaml .Values.resources | indent 10 }} |
| 115 | {{- if .Values.nodeSelector }} |
| 116 | nodeSelector: |
| 117 | {{ toYaml .Values.nodeSelector | indent 8 }} |
| 118 | {{- end -}} |
| 119 | {{- if .Values.affinity }} |
| 120 | affinity: |
| 121 | {{ toYaml .Values.affinity | indent 8 }} |
| 122 | {{- end }} |
| 123 | volumes: |
| 124 | - name: localtime |
| 125 | hostPath: |
| 126 | path: /etc/localtime |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 127 | {{- range $key, $value := .Values.configOverrides }} |
| 128 | - name: cassandra-config-{{ $key | replace "." "-" }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 129 | configMap: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 130 | name: {{ include "common.fullname" . }}-configOverrides |
| 131 | {{- end }} |
mahendrr | 8b20f77 | 2019-05-03 06:50:10 +0000 | [diff] [blame] | 132 | - name: cassandra-entrypoint |
| 133 | configMap: |
| 134 | name: {{ include "common.fullname" . }}-entrypoint |
| 135 | defaultMode: 0755 |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 136 | {{- if not .Values.persistence.enabled }} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 137 | - name: {{ include "common.fullname" . }}-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 138 | emptyDir: {} |
| 139 | {{- else }} |
| 140 | volumeClaimTemplates: |
| 141 | - metadata: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 142 | name: {{ include "common.fullname" . }}-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 143 | labels: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 144 | name: {{ include "common.fullname" . }} |
| 145 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 146 | release: "{{ include "common.release" . }}" |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 147 | heritage: "{{ .Release.Service }}" |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 148 | spec: |
| 149 | accessModes: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 150 | {{- if .Values.backup.enabled }} |
| 151 | - ReadWriteMany |
| 152 | {{- else }} |
| 153 | - ReadWriteOnce |
| 154 | {{- end }} |
| 155 | storageClassName: {{ include "common.storageClass" . }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 156 | resources: |
| 157 | requests: |
| 158 | storage: {{ .Values.persistence.size | quote }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 159 | {{- end }} |