Skip to content

Commit 044d11d

Browse files
committed
Replace master/slave with primary/secondary where possible
1 parent 8cb0b19 commit 044d11d

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

content/en/docs/tasks/run-application/run-replicated-stateful-application.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ weight: 30
1515

1616
This page shows how to run a replicated stateful application using a
1717
[StatefulSet](/docs/concepts/workloads/controllers/statefulset/) controller.
18-
The example is a MySQL single-master topology with multiple slaves running
18+
The example is a MySQL single-primary topology with multiple secondaries running
1919
asynchronous replication.
2020

2121
{{< note >}}
@@ -69,9 +69,9 @@ kubectl apply -f https://k8s.io/examples/application/mysql/mysql-configmap.yaml
6969
```
7070

7171
This ConfigMap provides `my.cnf` overrides that let you independently control
72-
configuration on the MySQL master and slaves.
73-
In this case, you want the master to be able to serve replication logs to slaves
74-
and you want slaves to reject any writes that don't come via replication.
72+
configuration on the MySQL primary and secondaries.
73+
In this case, you want the primary to be able to serve replication logs to secondaries
74+
and you want secondaries to reject any writes that don't come via replication.
7575

7676
There's nothing special about the ConfigMap itself that causes different
7777
portions to apply to different Pods.
@@ -96,12 +96,12 @@ cluster and namespace.
9696

9797
The Client Service, called `mysql-read`, is a normal Service with its own
9898
cluster IP that distributes connections across all MySQL Pods that report
99-
being Ready. The set of potential endpoints includes the MySQL master and all
100-
slaves.
99+
being Ready. The set of potential endpoints includes the MySQL primary and all
100+
secondaries.
101101

102102
Note that only read queries can use the load-balanced Client Service.
103-
Because there is only one MySQL master, clients should connect directly to the
104-
MySQL master Pod (through its DNS entry within the Headless Service) to execute
103+
Because there is only one MySQL primary, clients should connect directly to the
104+
MySQL primary Pod (through its DNS entry within the Headless Service) to execute
105105
writes.
106106

107107
### StatefulSet
@@ -167,33 +167,33 @@ This translates the unique, stable identity provided by the StatefulSet
167167
controller into the domain of MySQL server IDs, which require the same
168168
properties.
169169

170-
The script in the `init-mysql` container also applies either `master.cnf` or
171-
`slave.cnf` from the ConfigMap by copying the contents into `conf.d`.
172-
Because the example topology consists of a single MySQL master and any number of
173-
slaves, the script simply assigns ordinal `0` to be the master, and everyone
174-
else to be slaves.
170+
The script in the `init-mysql` container also applies either `primary.cnf` or
171+
`secondary.cnf` from the ConfigMap by copying the contents into `conf.d`.
172+
Because the example topology consists of a single MySQL primary and any number of
173+
secondaries, the script simply assigns ordinal `0` to be the primary, and everyone
174+
else to be secondaries.
175175
Combined with the StatefulSet controller's
176176
[deployment order guarantee](/docs/concepts/workloads/controllers/statefulset/#deployment-and-scaling-guarantees/),
177-
this ensures the MySQL master is Ready before creating slaves, so they can begin
177+
this ensures the MySQL primary is Ready before creating secondaries, so they can begin
178178
replicating.
179179

180180
### Cloning existing data
181181

182-
In general, when a new Pod joins the set as a slave, it must assume the MySQL
183-
master might already have data on it. It also must assume that the replication
182+
In general, when a new Pod joins the set as a secondary, it must assume the MySQL
183+
primary might already have data on it. It also must assume that the replication
184184
logs might not go all the way back to the beginning of time.
185185
These conservative assumptions are the key to allow a running StatefulSet
186186
to scale up and down over time, rather than being fixed at its initial size.
187187

188188
The second Init Container, named `clone-mysql`, performs a clone operation on
189-
a slave Pod the first time it starts up on an empty PersistentVolume.
189+
a secondary Pod the first time it starts up on an empty PersistentVolume.
190190
That means it copies all existing data from another running Pod,
191-
so its local state is consistent enough to begin replicating from the master.
191+
so its local state is consistent enough to begin replicating from the primary.
192192

193193
MySQL itself does not provide a mechanism to do this, so the example uses a
194194
popular open-source tool called Percona XtraBackup.
195195
During the clone, the source MySQL server might suffer reduced performance.
196-
To minimize impact on the MySQL master, the script instructs each Pod to clone
196+
To minimize impact on the MySQL primary, the script instructs each Pod to clone
197197
from the Pod whose ordinal index is one lower.
198198
This works because the StatefulSet controller always ensures Pod `N` is
199199
Ready before starting Pod `N+1`.
@@ -206,15 +206,15 @@ server, and an `xtrabackup` container that acts as a
206206
[sidecar](https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns).
207207

208208
The `xtrabackup` sidecar looks at the cloned data files and determines if
209-
it's necessary to initialize MySQL replication on the slave.
209+
it's necessary to initialize MySQL replication on the secondary.
210210
If so, it waits for `mysqld` to be ready and then executes the
211211
`CHANGE MASTER TO` and `START SLAVE` commands with replication parameters
212212
extracted from the XtraBackup clone files.
213213

214-
Once a slave begins replication, it remembers its MySQL master and
214+
Once a secondary begins replication, it remembers its MySQL primary and
215215
reconnects automatically if the server restarts or the connection dies.
216-
Also, because slaves look for the master at its stable DNS name
217-
(`mysql-0.mysql`), they automatically find the master even if it gets a new
216+
Also, because secondaries look for the primary at its stable DNS name
217+
(`mysql-0.mysql`), they automatically find the primary even if it gets a new
218218
Pod IP due to being rescheduled.
219219

220220
Lastly, after starting replication, the `xtrabackup` container listens for
@@ -224,7 +224,7 @@ case the next Pod loses its PersistentVolumeClaim and needs to redo the clone.
224224

225225
## Sending client traffic
226226

227-
You can send test queries to the MySQL master (hostname `mysql-0.mysql`)
227+
You can send test queries to the MySQL primary (hostname `mysql-0.mysql`)
228228
by running a temporary container with the `mysql:5.7` image and running the
229229
`mysql` client binary.
230230

@@ -291,7 +291,7 @@ it running in another window so you can see the effects of the following steps.
291291

292292
## Simulating Pod and Node downtime
293293

294-
To demonstrate the increased availability of reading from the pool of slaves
294+
To demonstrate the increased availability of reading from the pool of secondaries
295295
instead of a single server, keep the `SELECT @@server_id` loop from above
296296
running while you force a Pod out of the Ready state.
297297

@@ -409,9 +409,9 @@ Now uncordon the Node to return it to a normal state:
409409
kubectl uncordon <node-name>
410410
```
411411

412-
## Scaling the number of slaves
412+
## Scaling the number of secondaries
413413

414-
With MySQL replication, you can scale your read query capacity by adding slaves.
414+
With MySQL replication, you can scale your read query capacity by adding secondaries.
415415
With StatefulSet, you can do this with a single command:
416416

417417
```shell

content/en/examples/application/mysql/mysql-configmap.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ metadata:
55
labels:
66
app: mysql
77
data:
8-
master.cnf: |
9-
# Apply this config only on the master.
8+
primary.cnf: |
9+
# Apply this config only on the primary.
1010
[mysqld]
1111
log-bin
12-
slave.cnf: |
13-
# Apply this config only on slaves.
12+
secondary.cnf: |
13+
# Apply this config only on secondaries.
1414
[mysqld]
1515
super-read-only
1616

content/en/examples/application/mysql/mysql-services.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ spec:
1414
app: mysql
1515
---
1616
# Client service for connecting to any MySQL instance for reads.
17-
# For writes, you must instead connect to the master: mysql-0.mysql.
17+
# For writes, you must instead connect to the primary: mysql-0.mysql.
1818
apiVersion: v1
1919
kind: Service
2020
metadata:

content/en/examples/application/mysql/mysql-statefulset.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ spec:
2929
echo server-id=$((100 + $ordinal)) >> /mnt/conf.d/server-id.cnf
3030
# Copy appropriate conf.d files from config-map to emptyDir.
3131
if [[ $ordinal -eq 0 ]]; then
32-
cp /mnt/config-map/master.cnf /mnt/conf.d/
32+
cp /mnt/config-map/primary.cnf /mnt/conf.d/
3333
else
34-
cp /mnt/config-map/slave.cnf /mnt/conf.d/
34+
cp /mnt/config-map/secondary.cnf /mnt/conf.d/
3535
fi
3636
volumeMounts:
3737
- name: conf
@@ -47,7 +47,7 @@ spec:
4747
set -ex
4848
# Skip the clone if data already exists.
4949
[[ -d /var/lib/mysql/mysql ]] && exit 0
50-
# Skip the clone on master (ordinal index 0).
50+
# Skip the clone on primary (ordinal index 0).
5151
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1
5252
ordinal=${BASH_REMATCH[1]}
5353
[[ $ordinal -eq 0 ]] && exit 0
@@ -108,12 +108,12 @@ spec:
108108
# Determine binlog position of cloned data, if any.
109109
if [[ -f xtrabackup_slave_info && "x$(<xtrabackup_slave_info)" != "x" ]]; then
110110
# XtraBackup already generated a partial "CHANGE MASTER TO" query
111-
# because we're cloning from an existing slave. (Need to remove the tailing semicolon!)
111+
# because we're cloning from an existing secondary. (Need to remove the tailing semicolon!)
112112
cat xtrabackup_slave_info | sed -E 's/;$//g' > change_master_to.sql.in
113113
# Ignore xtrabackup_binlog_info in this case (it's useless).
114114
rm -f xtrabackup_slave_info xtrabackup_binlog_info
115115
elif [[ -f xtrabackup_binlog_info ]]; then
116-
# We're cloning directly from master. Parse binlog position.
116+
# We're cloning directly from primary. Parse binlog position.
117117
[[ `cat xtrabackup_binlog_info` =~ ^(.*?)[[:space:]]+(.*?)$ ]] || exit 1
118118
rm -f xtrabackup_binlog_info xtrabackup_slave_info
119119
echo "CHANGE MASTER TO MASTER_LOG_FILE='${BASH_REMATCH[1]}',\

0 commit comments

Comments
 (0)