[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 name: mysql
labels: labels:
app: mysql app: mysql
app.kubernetes.io/name: mysql
data: data:
primary.cnf: | primary.cnf: |
# Apply this config only on the primary. # 仅在主服务器上应用此配置
[mysqld] [mysqld]
log-bin log-bin
datadir=/var/lib/mysql/mysql
replica.cnf: | replica.cnf: |
# Apply this config only on replicas. # 仅在副本服务器上应用此配置
[mysqld] [mysqld]
super-read-only 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 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: mysql name: mysql
labels: labels:
app: mysql app: mysql
app.kubernetes.io/name: mysql
spec: spec:
ports: ports:
- name: mysql - name: mysql
@ -13,14 +14,16 @@ spec:
selector: selector:
app: mysql app: mysql
--- ---
# Client service for connecting to any MySQL instance for reads. # 用于连接到任一 MySQL 实例执行读操作的客户端服务
# For writes, you must instead connect to the primary: mysql-0.mysql. # 对于写操作你必须连接到主服务器mysql-0.mysql
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: mysql-read name: mysql-read
labels: labels:
app: mysql app: mysql
app.kubernetes.io/name: mysql
readonly: "true"
spec: spec:
ports: ports:
- name: mysql - name: mysql

View File

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