Merge pull request #2292 from enisoc/mysql-statefulset

[MySQL StatefulSet] Use subPath to keep data dir out of volume root.
This commit is contained in:
Andrew Chen
2017-01-24 11:37:46 -08:00
committed by GitHub
@@ -16,8 +16,6 @@ spec:
"image": "mysql:5.7", "image": "mysql:5.7",
"command": ["bash", "-c", " "command": ["bash", "-c", "
set -ex\n set -ex\n
# mysqld --initialize expects an empty data dir.\n
rm -rf /mnt/data/lost+found\n
# Generate mysql server-id from pod ordinal index.\n # Generate mysql server-id from pod ordinal index.\n
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1\n [[ `hostname` =~ -([0-9]+)$ ]] || exit 1\n
ordinal=${BASH_REMATCH[1]}\n ordinal=${BASH_REMATCH[1]}\n
@@ -32,7 +30,6 @@ spec:
fi\n fi\n
"], "],
"volumeMounts": [ "volumeMounts": [
{"name": "data", "mountPath": "/mnt/data"},
{"name": "conf", "mountPath": "/mnt/conf.d"}, {"name": "conf", "mountPath": "/mnt/conf.d"},
{"name": "config-map", "mountPath": "/mnt/config-map"} {"name": "config-map", "mountPath": "/mnt/config-map"}
] ]
@@ -54,7 +51,7 @@ spec:
xtrabackup --prepare --target-dir=/var/lib/mysql\n xtrabackup --prepare --target-dir=/var/lib/mysql\n
"], "],
"volumeMounts": [ "volumeMounts": [
{"name": "data", "mountPath": "/var/lib/mysql"}, {"name": "data", "mountPath": "/var/lib/mysql", "subPath": "mysql"},
{"name": "conf", "mountPath": "/etc/mysql/conf.d"} {"name": "conf", "mountPath": "/etc/mysql/conf.d"}
] ]
} }
@@ -72,6 +69,7 @@ spec:
volumeMounts: volumeMounts:
- name: data - name: data
mountPath: /var/lib/mysql mountPath: /var/lib/mysql
subPath: mysql
- name: conf - name: conf
mountPath: /etc/mysql/conf.d mountPath: /etc/mysql/conf.d
resources: resources:
@@ -140,6 +138,7 @@ spec:
volumeMounts: volumeMounts:
- name: data - name: data
mountPath: /var/lib/mysql mountPath: /var/lib/mysql
subPath: mysql
- name: conf - name: conf
mountPath: /etc/mysql/conf.d mountPath: /etc/mysql/conf.d
resources: resources: