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