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