[zh-cn] Resync some MySQL example YAMLs

pull/34580/head
Qiming Teng 2022-06-25 11:28:00 +08:00
parent a9b7331f57
commit 1c461b64d5
3 changed files with 11 additions and 8 deletions

View File

@ -4,15 +4,14 @@ metadata:
name: mysql
labels:
app: mysql
app.kubernetes.io/name: mysql
data:
primary.cnf: |
# Apply this config only on the primary.
# 仅在主服务器上应用此配置
[mysqld]
log-bin
datadir=/var/lib/mysql/mysql
replica.cnf: |
# Apply this config only on replicas.
# 仅在副本服务器上应用此配置
[mysqld]
super-read-only
datadir=/var/lib/mysql/mysql

View File

@ -1,10 +1,11 @@
# Headless service for stable DNS entries of StatefulSet members.
# 为 StatefulSet 成员提供稳定的 DNS 表项的无头服务Headless Service
apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql
app.kubernetes.io/name: mysql
spec:
ports:
- name: mysql
@ -13,14 +14,16 @@ spec:
selector:
app: mysql
---
# Client service for connecting to any MySQL instance for reads.
# For writes, you must instead connect to the primary: mysql-0.mysql.
# 用于连接到任一 MySQL 实例执行读操作的客户端服务
# 对于写操作你必须连接到主服务器mysql-0.mysql
apiVersion: v1
kind: Service
metadata:
name: mysql-read
labels:
app: mysql
app.kubernetes.io/name: mysql
readonly: "true"
spec:
ports:
- name: mysql

View File

@ -6,12 +6,14 @@ spec:
selector:
matchLabels:
app: mysql
app.kubernetes.io/name: mysql
serviceName: mysql
replicas: 3
template:
metadata:
labels:
app: mysql
app.kubernetes.io/name: mysql
spec:
initContainers:
- name: init-mysql
@ -27,7 +29,6 @@ spec:
echo [mysqld] > /mnt/conf.d/server-id.cnf
# 添加偏移量以避免使用 server-id=0 这一保留值。
echo server-id=$((100 + $ordinal)) >> /mnt/conf.d/server-id.cnf
# Copy appropriate conf.d files from config-map to emptyDir.
# 将合适的 conf.d 文件从 config-map 复制到 emptyDir。
if [[ $ordinal -eq 0 ]]; then
cp /mnt/config-map/primary.cnf /mnt/conf.d/