Krzysztof Opasiak | c0a57f8 | 2020-03-23 15:50:13 +0100 | [diff] [blame] | 1 | {{/* |
a.sreekumar | cf3133d | 2021-09-10 14:41:30 +0100 | [diff] [blame] | 2 | # Copyright © 2018 Amdocs |
| 3 | # Copyright © 2018,2021 Bell Canada |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 4 | # Copyright © 2019 Samsung Electronics |
| 5 | # Copyright © 2019-2020 Orange |
| 6 | # Copyright © 2020 Bitnami |
vaibhavjayas | ea9aee0 | 2018-08-31 06:22:26 +0000 | [diff] [blame] | 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
Krzysztof Opasiak | c0a57f8 | 2020-03-23 15:50:13 +0100 | [diff] [blame] | 19 | */}} |
vaibhavjayas | ea9aee0 | 2018-08-31 06:22:26 +0000 | [diff] [blame] | 20 | |
Andreas Geissler | cfd8434 | 2023-08-16 17:18:49 +0200 | [diff] [blame] | 21 | {{- if not .Values.global.mariadbGalera.useOperator }} |
milaszki | 804afe7 | 2020-07-07 12:23:07 +0000 | [diff] [blame] | 22 | apiVersion: apps/v1 |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 23 | kind: StatefulSet |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 24 | metadata: {{- include "common.resourceMetadata" . | nindent 2 }} |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 25 | spec: |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 26 | podManagementPolicy: {{ .Values.podManagementPolicy }} |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 27 | replicas: {{ .Values.replicaCount }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 28 | selector: {{- include "common.selectors" . | nindent 4 }} |
| 29 | serviceName: {{ include "common.servicename" . }}-headless |
| 30 | updateStrategy: |
| 31 | type: {{ .Values.updateStrategy.type }} |
| 32 | {{- if (eq "Recreate" .Values.updateStrategy.type) }} |
| 33 | rollingUpdate: null |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 34 | {{- end }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 35 | template: |
| 36 | metadata: {{- include "common.templateMetadata" . | nindent 6 }} |
| 37 | spec: |
| 38 | {{ include "common.podSecurityContext" . | indent 6 | trim }} |
| 39 | initContainers: |
| 40 | # we shouldn't need this but for unknown reason, it's fsGroup is not |
| 41 | # applied |
| 42 | - name: fix-permission |
| 43 | command: |
| 44 | - /bin/sh |
| 45 | args: |
| 46 | - -c |
| 47 | - | |
| 48 | chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /data |
| 49 | chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /bootstrap/ |
| 50 | chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /tmp/ |
| 51 | {{- if .Values.mariadbConfiguration }} |
| 52 | cp /config/my.cnf /actual/my.cnf |
| 53 | chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /actual |
| 54 | {{- end }} |
| 55 | image: {{ include "repositoryGenerator.image.busybox" . }} |
| 56 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 57 | securityContext: |
| 58 | runAsUser: 0 |
| 59 | volumeMounts: |
| 60 | - name: previous-boot |
| 61 | mountPath: /bootstrap |
| 62 | - name: mariadb-tmp-folder |
| 63 | mountPath: /tmp |
| 64 | - name: {{ include "common.fullname" . }} |
| 65 | mountPath: /data |
| 66 | {{- if .Values.mariadbConfiguration }} |
| 67 | - name: mariadb-galera-starting-config |
| 68 | mountPath: /config/my.cnf |
| 69 | subPath: my.cnf |
| 70 | - name: mariadb-galera-actual-config |
| 71 | mountPath: /actual |
| 72 | {{- end }} |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 73 | containers: |
pramod | 47b1b82 | 2018-08-28 15:41:45 +0000 | [diff] [blame] | 74 | - name: {{ include "common.name" . }} |
Sylvain Desbureaux | 4106614 | 2020-11-19 17:12:46 +0100 | [diff] [blame] | 75 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }} |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 76 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy | quote}} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 77 | command: |
| 78 | - bash |
| 79 | - -ec |
| 80 | - | |
| 81 | {{- if (not (empty (.Values.galera.bootstrap.bootstrapFromNode | quote)))}} |
Jozsef Csongvai | ebc553b | 2022-03-04 16:08:26 -0500 | [diff] [blame] | 82 | {{- $fullname := include "common.fullname" . }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 83 | {{- $bootstrapFromNode := int .Values.galera.bootstrap.bootstrapFromNode }} |
| 84 | # Bootstrap from the indicated node |
| 85 | NODE_ID="${MY_POD_NAME#"{{ $fullname }}-"}" |
| 86 | if [[ "$NODE_ID" -eq "{{ $bootstrapFromNode }}" ]]; then |
| 87 | export MARIADB_GALERA_CLUSTER_BOOTSTRAP=yes |
| 88 | export MARIADB_GALERA_FORCE_SAFETOBOOTSTRAP={{ ternary "yes" "no" .Values.galera.bootstrap.forceSafeToBootstrap }} |
| 89 | fi |
| 90 | {{- end }} |
| 91 | exec /opt/bitnami/scripts/mariadb-galera/entrypoint.sh /opt/bitnami/scripts/mariadb-galera/run.sh |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 92 | env: |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 93 | - name: MY_POD_NAME |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 94 | valueFrom: |
| 95 | fieldRef: |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 96 | fieldPath: metadata.name |
| 97 | - name: BITNAMI_DEBUG |
| 98 | value: {{ ternary "true" "false" .Values.debug | quote }} |
Sylvain Desbureaux | db1a672 | 2021-01-04 14:45:11 +0100 | [diff] [blame] | 99 | - name: MARIADB_INIT_SLEEP_TIME |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 100 | value: {{ .Values.init_sleep_time | quote }} |
| 101 | - name: MARIADB_GALERA_CLUSTER_NAME |
| 102 | value: {{ .Values.galera.name | quote }} |
| 103 | - name: MARIADB_GALERA_CLUSTER_ADDRESS |
| 104 | value: "gcomm://{{ template "common.name" . }}-headless.{{ include "common.namespace" . }}.svc.{{ .Values.global.clusterDomain }}" |
Sylvain Desbureaux | cded110 | 2021-01-18 14:53:55 +0100 | [diff] [blame] | 105 | # Bitnami init script don't behave well in dual stack env. |
| 106 | # set it here as long as https://github.com/bitnami/charts/issues/4077 is not solved. |
| 107 | - name: MARIADB_GALERA_NODE_ADDRESS |
| 108 | valueFrom: |
| 109 | fieldRef: |
| 110 | fieldPath: status.podIP |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 111 | - name: MARIADB_ROOT_USER |
| 112 | value: {{ .Values.rootUser.user | quote }} |
| 113 | - name: MARIADB_ROOT_PASSWORD |
| 114 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 14 }} |
| 115 | - name: MARIADB_USER |
| 116 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.userCredentialsUID" .) "key" "login") | indent 14 }} |
| 117 | - name: MARIADB_PASSWORD |
| 118 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.userCredentialsUID" .) "key" "password") | indent 14 }} |
| 119 | - name: MARIADB_DATABASE |
| 120 | value: {{ .Values.db.name | quote }} |
| 121 | - name: MARIADB_GALERA_MARIABACKUP_USER |
| 122 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.backupCredentialsUID" .) "key" "login") | indent 14 }} |
| 123 | - name: MARIADB_GALERA_MARIABACKUP_PASSWORD |
| 124 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.backupCredentialsUID" .) "key" "password") | indent 14 }} |
| 125 | {{- if .Values.extraFlags }} |
| 126 | - name: MARIADB_EXTRA_FLAGS |
| 127 | value: {{ .Values.extraFlags | quote }} |
| 128 | {{- end }} |
| 129 | ports: {{ include "common.containerPorts" . | nindent 12 }} |
| 130 | {{- if .Values.livenessProbe.enabled }} |
| 131 | livenessProbe: |
| 132 | exec: |
| 133 | command: |
Sylvain Desbureaux | 7f09e76 | 2021-05-05 09:20:18 +0200 | [diff] [blame] | 134 | - sh |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 135 | - -ec |
| 136 | - | |
| 137 | exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD |
| 138 | initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} |
| 139 | periodSeconds: {{ .Values.livenessProbe.periodSeconds }} |
| 140 | timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} |
| 141 | successThreshold: {{ .Values.livenessProbe.successThreshold }} |
| 142 | failureThreshold: {{ .Values.livenessProbe.failureThreshold }} |
| 143 | {{- end }} |
| 144 | {{- if .Values.readinessProbe.enabled }} |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 145 | readinessProbe: |
| 146 | exec: |
| 147 | command: |
Sylvain Desbureaux | 7f09e76 | 2021-05-05 09:20:18 +0200 | [diff] [blame] | 148 | - sh |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 149 | - -ec |
| 150 | - | |
| 151 | exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD |
| 152 | initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} |
| 153 | periodSeconds: {{ .Values.readinessProbe.periodSeconds }} |
| 154 | timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} |
| 155 | successThreshold: {{ .Values.readinessProbe.successThreshold }} |
| 156 | failureThreshold: {{ .Values.readinessProbe.failureThreshold }} |
| 157 | {{- end }} |
Sylvain Desbureaux | 7f09e76 | 2021-05-05 09:20:18 +0200 | [diff] [blame] | 158 | {{- if .Values.startupProbe.enabled }} |
| 159 | startupProbe: |
| 160 | exec: |
| 161 | command: |
| 162 | - sh |
| 163 | - -ec |
| 164 | - | |
| 165 | exec mysqladmin status -u$MARIADB_ROOT_USER -p$MARIADB_ROOT_PASSWORD |
| 166 | initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }} |
| 167 | periodSeconds: {{ .Values.startupProbe.periodSeconds }} |
| 168 | timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }} |
| 169 | successThreshold: {{ .Values.startupProbe.successThreshold }} |
| 170 | failureThreshold: {{ .Values.startupProbe.failureThreshold }} |
| 171 | {{- end }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 172 | resources: {{ include "common.resources" . | nindent 12 }} |
| 173 | volumeMounts: |
| 174 | - name: previous-boot |
| 175 | mountPath: /opt/bitnami/mariadb/.bootstrap |
| 176 | - name: {{ include "common.fullname" . }} |
| 177 | mountPath: /bitnami/mariadb |
| 178 | - name: mariadb-tmp-folder |
| 179 | mountPath: /opt/bitnami/mariadb/tmp |
| 180 | {{- if .Values.mariadbConfiguration }} |
| 181 | - name: mariadb-galera-actual-config |
| 182 | mountPath: /opt/bitnami/mariadb/conf |
| 183 | {{- end }} |
| 184 | {{- if default false .Values.global.metrics.enabled }} |
| 185 | - name: {{ include "common.name" . }}-metrics |
| 186 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.metrics.image }} |
| 187 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.metrics.pullPolicy | quote}} |
| 188 | env: |
| 189 | - name: MARIADB_METRICS_EXTRA_FLAGS |
| 190 | value: {{ default "" (join " " .Values.metrics.extraFlags) | quote }} |
| 191 | - name: MARIADB_ROOT_USER |
| 192 | value: {{ .Values.rootUser.user | quote }} |
| 193 | - name: MARIADB_ROOT_PASSWORD |
| 194 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 14}} |
| 195 | command: |
| 196 | - sh |
| 197 | - -c |
| 198 | - | |
| 199 | DATA_SOURCE_NAME="$MARIADB_ROOT_USER:$MARIADB_ROOT_PASSWORD@(localhost:3306)/" /bin/mysqld_exporter $MARIADB_METRICS_EXTRA_FLAGS |
| 200 | ports: |
Andreas Geissler | ba1200c | 2022-04-07 17:02:59 +0200 | [diff] [blame] | 201 | - name: tcp-metrics |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 202 | containerPort: 9104 |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 203 | livenessProbe: |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 204 | httpGet: |
| 205 | path: /metrics |
Andreas Geissler | ba1200c | 2022-04-07 17:02:59 +0200 | [diff] [blame] | 206 | port: tcp-metrics |
a.sreekumar | cf3133d | 2021-09-10 14:41:30 +0100 | [diff] [blame] | 207 | initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }} |
| 208 | periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }} |
| 209 | timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }} |
| 210 | successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }} |
| 211 | failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 212 | readinessProbe: |
| 213 | httpGet: |
| 214 | path: /metrics |
Andreas Geissler | ba1200c | 2022-04-07 17:02:59 +0200 | [diff] [blame] | 215 | port: tcp-metrics |
a.sreekumar | cf3133d | 2021-09-10 14:41:30 +0100 | [diff] [blame] | 216 | initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }} |
| 217 | periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }} |
| 218 | timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }} |
| 219 | successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }} |
| 220 | failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 221 | {{ include "common.containerSecurityContext" . | indent 10 | trim }} |
| 222 | resources: {{- toYaml .Values.metrics.resources | nindent 12 }} |
| 223 | {{- end }} |
Andreas Geissler | bd0d31a | 2024-03-20 09:51:32 +0100 | [diff] [blame^] | 224 | {{- include "common.imagePullSecrets" . | nindent 6 }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 225 | {{- if .Values.schedulerName }} |
| 226 | schedulerName: {{ .Values.schedulerName | quote }} |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 227 | {{- end }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 228 | {{- if .Values.priorityClassName }} |
| 229 | priorityClassName: {{ .Values.priorityClassName }} |
| 230 | {{- end }} |
| 231 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}} |
| 232 | {{- if .Values.affinity }} |
Prabhjot Singh Sethi | e4629f3 | 2021-08-21 11:31:59 +0530 | [diff] [blame] | 233 | affinity: {{- include "common.tplValue" ( dict "value" .Values.affinity "context" $) | nindent 8 }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 234 | {{- else }} |
| 235 | affinity: |
| 236 | podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "context" $) | nindent 10 }} |
| 237 | podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "context" $) | nindent 10 }} |
| 238 | nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }} |
| 239 | {{- end }} |
| 240 | {{- if .Values.nodeSelector }} |
Prabhjot Singh Sethi | e4629f3 | 2021-08-21 11:31:59 +0530 | [diff] [blame] | 241 | nodeSelector: {{- include "common.tplValue" ( dict "value" .Values.nodeSelector "context" $) | nindent 8 }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 242 | {{- end }} |
| 243 | {{- if .Values.tolerations }} |
Prabhjot Singh Sethi | e4629f3 | 2021-08-21 11:31:59 +0530 | [diff] [blame] | 244 | tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" .) | nindent 8 }} |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 245 | {{- end }} |
| 246 | volumes: |
| 247 | - name: previous-boot |
| 248 | emptyDir: {} |
| 249 | - name: mariadb-tmp-folder |
| 250 | emptyDir: {} |
| 251 | {{- if .Values.mariadbConfiguration }} |
| 252 | - name: mariadb-galera-actual-config |
| 253 | emptyDir: {} |
| 254 | - name: mariadb-galera-starting-config |
| 255 | configMap: |
| 256 | name: {{ printf "%s-configuration" (include "common.fullname" .) }} |
| 257 | {{- end }} |
| 258 | {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }} |
| 259 | - name: {{ include "common.fullname" . }} |
| 260 | persistentVolumeClaim: |
| 261 | claimName: {{ .Values.persistence.existingClaim }} |
| 262 | {{- else if not .Values.persistence.enabled }} |
| 263 | - name: {{ include "common.fullname" . }} |
| 264 | emptyDir: {} |
| 265 | {{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} |
vitalied | 1e5876c | 2018-03-29 10:24:27 -0500 | [diff] [blame] | 266 | volumeClaimTemplates: |
Sylvain Desbureaux | 93a5b49 | 2020-11-27 11:07:42 +0100 | [diff] [blame] | 267 | - {{ include "common.PVCTemplate" (dict "dot" . "suffix" "data" "persistenceInfos" .Values.persistence) | indent 6 | trim }} |
BorislavG | df11cd5 | 2018-05-06 12:55:20 +0000 | [diff] [blame] | 268 | {{- end }} |
Andreas Geissler | cfd8434 | 2023-08-16 17:18:49 +0200 | [diff] [blame] | 269 | {{- end }} |