Code Review
/
oom.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
[MARIADB][COMMON] Add support for mariadb-operator
[oom.git]
/
kubernetes
/
common
/
mariadb-galera
/
templates
/
backup
/
cronjob.yaml
diff --git
a/kubernetes/common/mariadb-galera/templates/backup/cronjob.yaml
b/kubernetes/common/mariadb-galera/templates/backup/cronjob.yaml
index
210fbd0
..
4548626
100644
(file)
--- a/
kubernetes/common/mariadb-galera/templates/backup/cronjob.yaml
+++ b/
kubernetes/common/mariadb-galera/templates/backup/cronjob.yaml
@@
-15,7
+15,10
@@
# limitations under the License.
*/}}
# limitations under the License.
*/}}
-{{- if .Values.backup.enabled }}
+{{- if and .Values.backup.enabled .Values.global.mariadbGalera.useOperator }}
+{{ include "common.mariadbOpBackup" . }}
+{{ else }}
+{{- if and .Values.backup.enabled .Values.persistence.enabled }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
@@
-37,7
+40,10
@@
spec:
- name: mariadb-galera-backup-init
image: {{ include "repositoryGenerator.image.mariadb" . }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
- name: mariadb-galera-backup-init
image: {{ include "repositoryGenerator.image.mariadb" . }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
- {{ include "common.containerSecurityContext" . | indent 14 | trim }}
+ securityContext:
+ allowPrivilegeEscalation: false
+ privileged: false
+ readOnlyRootFilesystem: false
command:
- /bin/bash
- -c
command:
- /bin/bash
- -c
@@
-52,7
+58,7
@@
spec:
target_dir=/backup/backup-`date +%s`
mkdir -p $target_dir
target_dir=/backup/backup-`date +%s`
mkdir -p $target_dir
- mysqlhost={{ include "common.
servicename" . }}
.{{ include "common.namespace" . }}
+ mysqlhost={{ include "common.
fullname" . }}-0.{{ include "common.servicename" . }}-headless
.{{ include "common.namespace" . }}
mariabackup --backup --target-dir=$target_dir --user=root --password=$DB_PASS --host=$mysqlhost
mariabackup --backup --target-dir=$target_dir --user=root --password=$DB_PASS --host=$mysqlhost
@@
-74,17
+80,22
@@
spec:
env:
- name: DB_PASS
{{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 18 }}
env:
- name: DB_PASS
{{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 18 }}
- resources: {{ include "common.resources" . | nindent 1
2
}}
+ resources: {{ include "common.resources" . | nindent 1
6
}}
volumeMounts:
- name: backup-dir
mountPath: /backup
volumeMounts:
- name: backup-dir
mountPath: /backup
+ - name: data
+ mountPath: /bitnami/mariadb
containers:
- name: mariadb-backup-validate
image: {{ include "repositoryGenerator.image.mariadb" . }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
containers:
- name: mariadb-backup-validate
image: {{ include "repositoryGenerator.image.mariadb" . }}
imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
- {{ include "common.containerSecurityContext" . | indent 14 | trim }}
+ securityContext:
+ allowPrivilegeEscalation: false
+ privileged: false
+ readOnlyRootFilesystem: false
env:
env:
- - name: M
YSQL
_ROOT_PASSWORD
+ - name: M
ARIADB
_ROOT_PASSWORD
{{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 18 }}
command:
- /bin/bash
{{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.mariadb.secret.rootPassUID" .) "key" "password") | indent 18 }}
command:
- /bin/bash
@@
-105,17
+116,17
@@
spec:
fi
target_dir=$(ls -td -- /backup/backup-* | head -n 1)
fi
target_dir=$(ls -td -- /backup/backup-* | head -n 1)
- cp -Ra $target_dir/* /
var/lib/mysql/
+ cp -Ra $target_dir/* /
bitnami/mariadb/data
- if [ ! "$(ls -A /
var/lib/mysql
)" ]; then
+ if [ ! "$(ls -A /
bitnami/mariadb/data
)" ]; then
remove_dir $target_dir
exit 0
fi
remove_dir $target_dir
exit 0
fi
- /
docker-entrypoint.sh mysqld
&
+ /
opt/bitnami/scripts/mariadb/entrypoint.sh /opt/bitnami/scripts/mariadb/run.sh
&
count=0
count=0
- until mysql --user=root --password=$M
YSQL
_ROOT_PASSWORD -e "SELECT 1";
+ until mysql --user=root --password=$M
ARIADB
_ROOT_PASSWORD -e "SELECT 1";
do sleep 3;
count=`expr $count + 1`;
if [ $count -ge 30 ]; then
do sleep 3;
count=`expr $count + 1`;
if [ $count -ge 30 ]; then
@@
-124,7
+135,7
@@
spec:
fi;
done
fi;
done
- mysqlcheck -A --user=root --password=$M
YSQL
_ROOT_PASSWORD > /tmp/output.log
+ mysqlcheck -A --user=root --password=$M
ARIADB
_ROOT_PASSWORD > /tmp/output.log
error_lines=`cat /tmp/output.log| grep -v "OK" | wc -l`
cat /tmp/output.log
error_lines=`cat /tmp/output.log| grep -v "OK" | wc -l`
cat /tmp/output.log
@@
-140,8
+151,12
@@
spec:
ls -tr | grep backup | head -$filestoDelete | xargs rm -rf
fi
fi
ls -tr | grep backup | head -$filestoDelete | xargs rm -rf
fi
fi
- resources: {{ include "common.resources" . | nindent 1
2
}}
+ resources: {{ include "common.resources" . | nindent 1
6
}}
volumeMounts:
volumeMounts:
+ - mountPath: /bitnami/mariadb/data
+ name: tmp-data
+ - mountPath: /opt/bitnami/mariadb/tmp
+ name: tmp
- mountPath: /etc/localtime
name: localtime
readOnly: true
- mountPath: /etc/localtime
name: localtime
readOnly: true
@@
-153,7
+168,19
@@
spec:
- name: localtime
hostPath:
path: /etc/localtime
- name: localtime
hostPath:
path: /etc/localtime
+ - name: data
+ persistentVolumeClaim:
+ {{- if .Values.persistence.existingClaim }}
+ claimName: {{ .Values.persistence.existingClaim }}
+ {{- else }}
+ claimName: {{ include "common.fullname" . }}-{{ include "common.fullname" . }}-0
+ {{- end }}
- name: backup-dir
persistentVolumeClaim:
claimName: {{ include "common.fullname" . }}-backup-data
- name: backup-dir
persistentVolumeClaim:
claimName: {{ include "common.fullname" . }}-backup-data
+ - name: tmp-data
+ emptyDir: {}
+ - name: tmp
+ emptyDir: {}
+{{- end }}
{{- end }}
{{- end }}