Jakub Latusek | 3659d9f | 2020-09-14 16:21:55 +0200 | [diff] [blame] | 1 | {{/* |
Suresh Charan | e1a70a1 | 2022-01-13 06:56:53 -0500 | [diff] [blame] | 2 | # Copyright © 2022 Amdocs, AT&T, Bell Canada, Bitnami |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 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 | |
dasarathi528024 | 65e8f78 | 2023-05-03 09:51:20 +0000 | [diff] [blame^] | 17 | {{- if not .Values.k8ssandraOperator.enabled }} |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 18 | apiVersion: apps/v1 |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 19 | kind: StatefulSet |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 20 | metadata: {{- include "common.resourceMetadata" . | nindent 2 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 21 | spec: |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 22 | selector: {{- include "common.selectors" . | nindent 4 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 23 | serviceName: {{ include "common.servicename" . }} |
| 24 | replicas: {{ .Values.replicaCount }} |
| 25 | podManagementPolicy: {{ .Values.podManagementPolicy }} |
| 26 | updateStrategy: |
| 27 | type: {{ .Values.updateStrategy.type }} |
| 28 | template: |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 29 | metadata: {{- include "common.templateMetadata" . | nindent 6 }} |
Suresh Charan | e1a70a1 | 2022-01-13 06:56:53 -0500 | [diff] [blame] | 30 | {{- if or .Values.podAnnotations (and .Values.metrics.serviceMonitor.enabled .Values.metrics.podAnnotations) }} |
| 31 | annotations: |
| 32 | {{- if .Values.podAnnotations }} |
| 33 | {{- include "common.tplValue" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }} |
| 34 | {{- end }} |
| 35 | {{- if and .Values.metrics.serviceMonitor.enabled .Values.metrics.podAnnotations }} |
| 36 | {{- include "common.tplValue" (dict "value" .Values.metrics.podAnnotations "context" $) | nindent 8 }} |
| 37 | {{- end }} |
| 38 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 39 | spec: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 40 | hostNetwork: {{ .Values.hostNetwork }} |
andreas-geissler | f84cccd | 2021-07-07 15:40:41 +0200 | [diff] [blame] | 41 | imagePullSecrets: |
| 42 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 43 | containers: |
| 44 | - name: {{ include "common.name" . }} |
Sylvain Desbureaux | 7743d8b | 2020-11-19 16:45:23 +0100 | [diff] [blame] | 45 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 46 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
Sylvain Desbureaux | 60c7480 | 2019-12-12 14:35:01 +0100 | [diff] [blame] | 47 | ports: {{ include "common.containerPorts" . | nindent 8 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 48 | volumeMounts: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 49 | - name: {{ include "common.fullname" . }}-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 50 | mountPath: /var/lib/cassandra |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 51 | - name: localtime |
| 52 | mountPath: /etc/localtime |
| 53 | readOnly: true |
mahendrr | 8b20f77 | 2019-05-03 06:50:10 +0000 | [diff] [blame] | 54 | - name: cassandra-entrypoint |
| 55 | mountPath: /docker-entrypoint.sh |
| 56 | subPath: docker-entrypoint.sh |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 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: |
Sylvain Desbureaux | 7743d8b | 2020-11-19 16:45:23 +0100 | [diff] [blame] | 65 | command: |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 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 }} |
Joey Sullivan | bec0c98 | 2019-06-11 10:53:16 -0400 | [diff] [blame] | 74 | {{ end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 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 }} |
Sylvain Desbureaux | e7616c3 | 2021-05-05 10:47:58 +0200 | [diff] [blame] | 86 | startupProbe: |
| 87 | exec: |
| 88 | command: |
| 89 | - /bin/bash |
| 90 | - -c |
| 91 | - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }' |
| 92 | initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }} |
| 93 | periodSeconds: {{ .Values.startup.periodSeconds }} |
| 94 | timeoutSeconds: {{ .Values.startup.timeoutSeconds }} |
| 95 | successThreshold: {{ .Values.startup.successThreshold }} |
| 96 | failureThreshold: {{ .Values.startup.failureThreshold }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 97 | env: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 98 | {{- $seed_size := default 1 .Values.replicaCount | int -}} |
| 99 | {{- $global := . }} |
| 100 | - name: CASSANDRA_SEEDS |
| 101 | {{- if .Values.hostNetwork }} |
| 102 | value: {{ required "You must fill \".Values.config.seeds\" with list of Cassandra seeds when hostNetwork is set to true" .Values.config.seeds | quote }} |
| 103 | {{- else }} |
| 104 | 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 }}" |
| 105 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 106 | - name: MAX_HEAP_SIZE |
| 107 | value: {{ .Values.config.heap.max }} |
| 108 | - name: HEAP_NEWSIZE |
| 109 | value: {{ .Values.config.heap.min }} |
| 110 | - name: JVM_OPTS |
| 111 | value: {{ .Values.config.jvmOpts | quote }} |
| 112 | - name: CASSANDRA_CLUSTER_NAME |
| 113 | value: {{ .Values.config.clusterName | quote }} |
| 114 | - name: CASSANDRA_DC |
| 115 | value: {{ .Values.config.dataCenter | quote }} |
| 116 | - name: CASSANDRA_RACK |
| 117 | value: {{ .Values.config.rackName | quote }} |
| 118 | - name: CASSANDRA_AUTO_BOOTSTRAP |
| 119 | value: {{ .Values.config.autoBootstrap | quote }} |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 120 | - name: CASSANDRA_START_RPC |
| 121 | value: {{ default "true" .Values.config.start_rpc | quote }} |
| 122 | - name: CASSANDRA_ENDPOINT_SNITCH |
Mahendra Raghuwanshi | a9a4f31 | 2019-03-19 06:05:47 +0000 | [diff] [blame] | 123 | value: {{ default "GossipingPropertyFileSnitch" .Values.config.endpoint_snitch | quote }} |
mahendrr | 8b20f77 | 2019-05-03 06:50:10 +0000 | [diff] [blame] | 124 | - name: CASSANDRA_AUTHENTICATOR |
| 125 | value: {{ default "PasswordAuthenticator" .Values.config.authenticator | quote }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 126 | - name: POD_IP |
| 127 | valueFrom: |
| 128 | fieldRef: |
| 129 | fieldPath: status.podIP |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 130 | lifecycle: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 131 | preStop: |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 132 | exec: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 133 | {{- if not .Values.persistence.enabled }} |
| 134 | command: ["/bin/sh", "-c", "exec nodetool decommission"] |
| 135 | {{- else }} |
| 136 | command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"] |
| 137 | {{- end }} |
Sylvain Desbureaux | 77c848a | 2020-09-23 14:21:30 +0200 | [diff] [blame] | 138 | resources: {{ toYaml .Values.resources | nindent 10 }} |
Suresh Charan | e1a70a1 | 2022-01-13 06:56:53 -0500 | [diff] [blame] | 139 | {{- if .Values.metrics.serviceMonitor.enabled }} |
| 140 | - name: {{ include "common.name" . }}-metrics |
| 141 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.metrics.image }} |
| 142 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.metrics.pullPolicy | quote}} |
| 143 | {{- if (.Values.metrics.enabled) }} |
| 144 | ports: |
| 145 | {{- range $index, $metricPort := .Values.metrics.ports }} |
| 146 | - name: {{ $metricPort.name }} |
| 147 | containerPort: {{ $metricPort.port }} |
| 148 | protocol: TCP |
| 149 | {{- end }} |
| 150 | livenessProbe: |
| 151 | httpGet: |
| 152 | path: {{ .Values.metrics.livenessProbe.httpGet.path }} |
| 153 | port: {{ .Values.metrics.livenessProbe.httpGet.port }} |
| 154 | initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }} |
| 155 | periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }} |
| 156 | timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }} |
| 157 | successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }} |
| 158 | failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }} |
| 159 | readinessProbe: |
| 160 | httpGet: |
| 161 | path: {{ .Values.metrics.readinessProbe.httpGet.path }} |
| 162 | port: {{ .Values.metrics.readinessProbe.httpGet.port }} |
| 163 | initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }} |
| 164 | periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }} |
| 165 | timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }} |
| 166 | successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }} |
| 167 | failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }} |
| 168 | {{- end }} |
| 169 | {{ include "common.containerSecurityContext" . | indent 10 | trim }} |
| 170 | {{- if .Values.metrics.resources }} |
| 171 | resources: {{- toYaml .Values.metrics.resources | nindent 10 }} |
| 172 | {{- end }} |
| 173 | {{- end }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 174 | {{- if .Values.nodeSelector }} |
Sylvain Desbureaux | 77c848a | 2020-09-23 14:21:30 +0200 | [diff] [blame] | 175 | nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 176 | {{- end -}} |
| 177 | {{- if .Values.affinity }} |
Sylvain Desbureaux | 77c848a | 2020-09-23 14:21:30 +0200 | [diff] [blame] | 178 | affinity: {{ toYaml .Values.affinity | nindent 8 }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 179 | {{- end }} |
farida azmy | 661c81a | 2021-03-09 11:38:20 +0200 | [diff] [blame] | 180 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "nothing" "dot" . )}} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 181 | volumes: |
| 182 | - name: localtime |
| 183 | hostPath: |
| 184 | path: /etc/localtime |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 185 | {{- range $key, $value := .Values.configOverrides }} |
| 186 | - name: cassandra-config-{{ $key | replace "." "-" }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 187 | configMap: |
Mahendra Raghuwanshi | f59d925 | 2019-02-20 06:54:46 +0000 | [diff] [blame] | 188 | name: {{ include "common.fullname" . }}-configOverrides |
| 189 | {{- end }} |
mahendrr | 8b20f77 | 2019-05-03 06:50:10 +0000 | [diff] [blame] | 190 | - name: cassandra-entrypoint |
| 191 | configMap: |
| 192 | name: {{ include "common.fullname" . }}-entrypoint |
| 193 | defaultMode: 0755 |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 194 | {{- if not .Values.persistence.enabled }} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 195 | - name: {{ include "common.fullname" . }}-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 196 | emptyDir: {} |
| 197 | {{- else }} |
| 198 | volumeClaimTemplates: |
| 199 | - metadata: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 200 | name: {{ include "common.fullname" . }}-data |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 201 | labels: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 202 | name: {{ include "common.fullname" . }} |
| 203 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 204 | release: "{{ include "common.release" . }}" |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 205 | heritage: "{{ .Release.Service }}" |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 206 | spec: |
| 207 | accessModes: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 208 | {{- if .Values.backup.enabled }} |
| 209 | - ReadWriteMany |
| 210 | {{- else }} |
| 211 | - ReadWriteOnce |
| 212 | {{- end }} |
| 213 | storageClassName: {{ include "common.storageClass" . }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 214 | resources: |
| 215 | requests: |
| 216 | storage: {{ .Values.persistence.size | quote }} |
prpatel | afedf2c | 2018-09-07 15:28:38 +0000 | [diff] [blame] | 217 | {{- end }} |
dasarathi528024 | 65e8f78 | 2023-05-03 09:51:20 +0000 | [diff] [blame^] | 218 | {{- end }} |