Skip to content

Commit

Permalink
Demonstrate master/slave ConfigMap entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
enisoc committed Nov 19, 2016
1 parent 2aad79e commit 47149b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
5 changes: 0 additions & 5 deletions docs/tutorials/replicated-stateful-application/my.cnf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql
data:
master.cnf: |
# Apply this config only on the master.
[mysqld]
log-bin
slave.cnf: |
# Apply this config only on slaves.
[mysqld]
super-read-only
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ spec:
set -ex\n
# mysqld --initialize expects an empty data dir.\n
rm -rf /mnt/data/lost+found\n
# Copy conf.d from config-map to emptyDir.\n
cp /mnt/config-map/* /mnt/conf.d/\n
# Generate mysql server-id from pod ordinal index.\n
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1\n
ordinal=${BASH_REMATCH[1]}\n
echo [mysqld] > /mnt/conf.d/server-id.cnf\n
# Add an offset to avoid reserved server-id=0 value.\n
echo server-id=$((100 + ${BASH_REMATCH[1]})) >> /mnt/conf.d/server-id.cnf\n
echo server-id=$((100 + $ordinal)) >> /mnt/conf.d/server-id.cnf\n
# Copy appropriate conf.d files from config-map to emptyDir.\n
if [[ $ordinal -eq 0 ]]; then\n
cp /mnt/config-map/master.cnf /mnt/conf.d/\n
else\n
cp /mnt/config-map/slave.cnf /mnt/conf.d/\n
fi\n
"],
"volumeMounts": [
{"name": "data", "mountPath": "/mnt/data"},
Expand Down Expand Up @@ -102,7 +107,7 @@ spec:
# because we're cloning from an existing slave.
mv xtrabackup_slave_info change_master_to.sql.in
# Ignore xtrabackup_binlog_info in this case (it's useless).
rm xtrabackup_binlog_info
rm -f xtrabackup_binlog_info
elif [[ -f xtrabackup_binlog_info ]]; then
# We're cloning directly from master. Parse binlog position.
[[ `cat xtrabackup_binlog_info` =~ ^(.*?)[[:space:]]+(.*?)$ ]] || exit 1
Expand Down

0 comments on commit 47149b3

Please sign in to comment.